create_account.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <div class="app-container">
  3. <div v-show="step == 1">
  4. <div class="setting_title">开通账号</div>
  5. <el-divider></el-divider>
  6. <div class="tips">说明:开通商户账号是指开通商城后台管理系统的总登录账号。</div>
  7. <el-card shadow="never" class="my-card">
  8. <el-form
  9. class="my-form"
  10. ref="mainForm"
  11. :model="mainForm"
  12. :rules="mainFormRules"
  13. label-width="120px"
  14. label-position="right"
  15. >
  16. <el-form-item label="商户账号" prop="account">
  17. <el-input v-model="mainForm.account" autocomplete="off" placeholder="请输入商户账号"></el-input>
  18. <el-popover
  19. class="question"
  20. placement="right-start"
  21. title="账号设置"
  22. width="260"
  23. trigger="hover"
  24. content="账号设置需按数字、字母组合设置至少12位账号"
  25. >
  26. <svg-icon icon-class="question" slot="reference" />
  27. </el-popover>
  28. </el-form-item>
  29. <el-form-item label="账户昵称" prop="nickName">
  30. <el-input v-model="mainForm.nickName" autocomplete="off" placeholder="请输入账户昵称"></el-input>
  31. </el-form-item>
  32. <el-form-item label="负责人" prop="chargePerson">
  33. <el-input v-model="mainForm.chargePerson" autocomplete="off" placeholder="请输入负责人"></el-input>
  34. </el-form-item>
  35. <el-form-item label="联系电话" prop="phone">
  36. <el-input v-model="mainForm.phone" autocomplete="off" placeholder="请输入联系电话"></el-input>
  37. </el-form-item>
  38. <el-form-item label="金蝶主体账号" prop="kingdeeId">
  39. <el-input v-model="mainForm.kingdeeId" autocomplete="off" placeholder="请输入金蝶主体账号"></el-input>
  40. </el-form-item>
  41. <el-form-item label="金蝶主体名称" prop="kingdeeName">
  42. <el-input v-model="mainForm.kingdeeName" autocomplete="off" placeholder="请输入金蝶主体名称"></el-input>
  43. </el-form-item>
  44. <el-form-item label="电子邮箱" prop="email">
  45. <el-input v-model="mainForm.email" autocomplete="off" placeholder="请输入电子邮箱"></el-input>
  46. </el-form-item>
  47. <el-form-item label="地址" prop="address">
  48. <el-input v-model="mainForm.address" placeholder="请输入地址"></el-input>
  49. </el-form-item>
  50. <el-form-item label="登录密码" prop="newPassword">
  51. <el-input
  52. v-model="mainForm.newPassword"
  53. ref="password1"
  54. auto-complete="new-password"
  55. placeholder="请输入登录密码"
  56. :type="passwordType1"
  57. ></el-input>
  58. <span class="show-pwd" @click="showPwd(1)">
  59. <svg-icon :icon-class="passwordType1 === 'password' ? 'eye' : 'eye-open'" />
  60. </span>
  61. <el-popover
  62. class="question"
  63. placement="right-start"
  64. title="密码设置"
  65. width="260"
  66. trigger="hover"
  67. content="密码设置需按数字、字母组合设置至少12位密码"
  68. >
  69. <svg-icon icon-class="question" slot="reference" />
  70. </el-popover>
  71. </el-form-item>
  72. <el-form-item label="确认密码" prop="confirmPassword">
  73. <el-input
  74. v-model="mainForm.confirmPassword"
  75. ref="password2"
  76. auto-complete="confirm-password"
  77. placeholder="请再次输入密码"
  78. :type="passwordType2"
  79. ></el-input>
  80. <span class="show-pwd" @click="showPwd(2)">
  81. <svg-icon :icon-class="passwordType2 === 'password' ? 'eye' : 'eye-open'" />
  82. </span>
  83. <el-popover
  84. class="question"
  85. placement="right-start"
  86. title="密码设置"
  87. width="260"
  88. trigger="hover"
  89. content="确认密码需要和登录密码保持一致"
  90. >
  91. <svg-icon icon-class="question" slot="reference" />
  92. </el-popover>
  93. </el-form-item>
  94. </el-form>
  95. </el-card>
  96. </div>
  97. <div class="page-footer">
  98. <div class="footer" :class="classObj">
  99. <el-button type="primary" @click="clickSubmitForm" :loading="formLoading">{{
  100. formLoading ? '提交中 ...' : '提 交'
  101. }}</el-button>
  102. <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px">
  103. <el-button slot="reference">关 闭</el-button>
  104. </el-popconfirm>
  105. </div>
  106. </div>
  107. </div>
  108. </template>
  109. <script>
  110. import { getToken } from '@/utils/auth'
  111. import { addAccount } from '@/api/merchant'
  112. export default {
  113. data() {
  114. var validateAccount = (rule, value, callback) => {
  115. if (value === '') {
  116. callback(new Error('请输入商户账号'))
  117. } else if (value.length < 12) {
  118. callback(new Error('账号长度至少12位'))
  119. } else if (/[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/.test(value) == false) {
  120. callback(new Error('账号必须包含数字和字母'))
  121. } else {
  122. callback()
  123. }
  124. }
  125. var validatePass3 = (rule, value, callback) => {
  126. if (value === '') {
  127. callback(new Error('请输入登录密码'))
  128. } else if (value.length < 12) {
  129. callback(new Error('密码长度至少12位'))
  130. } else if (/[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/.test(value) == false) {
  131. callback(new Error('密码必须包含数字和字母'))
  132. } else {
  133. if (this.mainForm.confirmPassword !== '') {
  134. this.$refs.mainForm.validateField('confirmPassword')
  135. }
  136. callback()
  137. }
  138. }
  139. var validatePass4 = (rule, value, callback) => {
  140. if (value === '') {
  141. callback(new Error('请再次输入密码'))
  142. } else if (value !== this.mainForm.newPassword) {
  143. callback(new Error('两次输入密码不一致'))
  144. } else {
  145. callback()
  146. }
  147. }
  148. return {
  149. baseURL: process.env.VUE_APP_BASE_API,
  150. myHeaders: { 'x-token': getToken() },
  151. step: 1,
  152. mainForm: {
  153. account: '', // 账号
  154. nickName: '', // 用户名
  155. appName: '', // 小程序名称
  156. chargePerson: '', // 负责人
  157. phone: '', // 联系电话
  158. kingdeeId: '',
  159. kingdeeName: '',
  160. email: '', // 电子邮箱
  161. address: '', // 地址
  162. newPassword: '', // 登录密码
  163. confirmPassword: '' // 确认密码
  164. },
  165. mainFormRules: {
  166. account: [{ required: true, validator: validateAccount, trigger: 'blur' }],
  167. nickName: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
  168. appName: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
  169. chargePerson: [{ required: true, message: '请输入负责人', trigger: 'blur' }],
  170. phone: [{ required: true, message: '请输入联系电话', trigger: 'blur' }],
  171. kingdeeId: [{ required: true, message: '请输入金蝶主体账号', trigger: 'blur' }],
  172. kingdeeName: [{ required: true, message: '请输入金蝶主体密码', trigger: 'blur' }],
  173. newPassword: [{ required: true, validator: validatePass3, trigger: 'blur' }],
  174. confirmPassword: [{ required: true, validator: validatePass4, trigger: 'blur' }]
  175. },
  176. passwordType1: 'password',
  177. passwordType2: 'password',
  178. formLoading: false
  179. }
  180. },
  181. computed: {
  182. sidebar() {
  183. return this.$store.state.app.sidebar
  184. },
  185. classObj() {
  186. return {
  187. hideSidebar: !this.sidebar.opened,
  188. openSidebar: this.sidebar.opened
  189. }
  190. }
  191. },
  192. methods: {
  193. goBack() {
  194. this.$router.go(-1)
  195. },
  196. // 显示隐藏密码
  197. showPwd(num) {
  198. if (num == 1) {
  199. if (this.passwordType1 === 'password') {
  200. this.passwordType1 = ''
  201. } else {
  202. this.passwordType1 = 'password'
  203. }
  204. this.$nextTick(() => {
  205. this.$refs.password1.focus()
  206. })
  207. }
  208. if (num == 2) {
  209. if (this.passwordType2 === 'password') {
  210. this.passwordType2 = ''
  211. } else {
  212. this.passwordType2 = 'password'
  213. }
  214. this.$nextTick(() => {
  215. this.$refs.password2.focus()
  216. })
  217. }
  218. },
  219. // 点击 提交表单
  220. clickSubmitForm() {
  221. this.$refs.mainForm.validate(valid => {
  222. if (valid) {
  223. this.submitForm()
  224. }
  225. })
  226. },
  227. // 提交表单
  228. submitForm() {
  229. this.formLoading = true
  230. let params = {
  231. adminCompanyName: this.mainForm.nickName,
  232. useOrgNumber: this.mainForm.kingdeeId,
  233. useOrgName: this.mainForm.kingdeeName,
  234. adminUser: {
  235. userName: this.mainForm.account,
  236. adminCompanyName: this.mainForm.nickName,
  237. linkName: this.mainForm.chargePerson,
  238. linkPhone: this.mainForm.phone,
  239. email: this.mainForm.email,
  240. address: this.mainForm.address,
  241. password: this.mainForm.confirmPassword
  242. }
  243. }
  244. addAccount(params)
  245. .then(res => {
  246. this.$successMsg('开通成功')
  247. setTimeout(() => {
  248. this.$router.push({
  249. path: '/merchant/merchant_list',
  250. query: {}
  251. })
  252. }, 1500)
  253. })
  254. .finally(res => {
  255. this.formLoading = false
  256. })
  257. }
  258. }
  259. }
  260. </script>
  261. <style lang="scss" scoped>
  262. .setting_title {
  263. padding-left: 0;
  264. }
  265. .tips {
  266. font-size: 14px;
  267. }
  268. .my-card {
  269. margin-top: 20px;
  270. .box {
  271. background: rgb(235, 240, 249);
  272. padding: 10px;
  273. font-size: 14px;
  274. margin: 20px 0;
  275. line-height: 18px;
  276. ::v-deep .el-link {
  277. vertical-align: unset;
  278. }
  279. }
  280. }
  281. .my-form {
  282. width: 450px;
  283. margin: 0 auto;
  284. }
  285. .show-pwd {
  286. position: absolute;
  287. right: 15px;
  288. top: 0;
  289. font-size: 16px;
  290. cursor: pointer;
  291. user-select: none;
  292. }
  293. .question {
  294. position: absolute;
  295. right: -30px;
  296. top: 0;
  297. font-size: 20px;
  298. cursor: pointer;
  299. user-select: none;
  300. }
  301. </style>