register.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <template>
  2. <view class="container">
  3. <u-cell-group class="form-info" :border="false">
  4. <u-form :model="shopInfo" ref="shopInfo">
  5. <!-- <u-form-item label="商家名称" prop="name">
  6. <u-input placeholder="请输入商家名称" label-width="180" v-model="shopInfo.name" /> -->
  7. <u-field label="商家名称" required placeholder="请输入商家名称" label-width="180" v-model="shopInfo.name"></u-field>
  8. <!-- </u-form-item> -->
  9. <u-cell-item title="请上传商家图标" :arrow="false">
  10. <view slot="label">
  11. <u-upload :action="uploadUrl" :file-list="defaultList1" :form-data="uploadData" @on-success="logoUploadSuccess"
  12. @on-error="uploadError" max-count="1"></u-upload>
  13. </view>
  14. </u-cell-item>
  15. <u-cell-item title="请上传店铺主图" :arrow="false" class="all-width">
  16. <view slot="label">
  17. <u-upload :action="uploadUrl" :file-list="defaultList2" :form-data="uploadData" @on-success="uploadSuccess"
  18. @on-error="uploadError" @on-remove="uploadRemove" max-count="3"></u-upload>
  19. </view>
  20. </u-cell-item>
  21. <u-cell-item title="请上传身份证正反面" :arrow="false" class="all-width">
  22. <view slot="label" class="id-card-box">
  23. <u-upload :action="uploadUrl" :file-list="defaultList3" :form-data="uploadData" @on-success="uploadIdCardSuccess1"
  24. @on-error="uploadError" :custom-btn="true" max-count="1" style="margin-right: 16px;" :style="{width: cWidth + 'px', height: (cWidth * 0.66 + 30) + 'px'}">
  25. <view slot="addBtn" class="id-card card-img1" :style="{width: cWidth + 'px', height: (cWidth * 0.66 + 30) + 'px', paddingTop: (cWidth * 0.66) + 'px', backgroundSize: '100% ' + (cWidth * 0.66) + 'px'}">拍摄正面</view>
  26. </u-upload>
  27. <u-upload :action="uploadUrl" :file-list="defaultList4" :form-data="uploadData" @on-success="uploadIdCardSuccess2"
  28. @on-error="uploadError" :custom-btn="true" max-count="1" :style="{width: cWidth + 'px', height: (cWidth * 0.66 + 30) + 'px'}">
  29. <view slot="addBtn" class="id-card card-img2" :style="{width: cWidth + 'px', height: (cWidth * 0.66 + 30) + 'px', paddingTop: (cWidth * 0.66) + 'px', backgroundSize: '100% ' + (cWidth * 0.66) + 'px'}">拍摄反面</view>
  30. </u-upload>
  31. </view>
  32. </u-cell-item>
  33. <u-cell-item title="请上传营业执照照片" required :arrow="false" class="all-width">
  34. <view slot="label" class="license-box">
  35. <u-upload :action="uploadUrl" :file-list="defaultList5" :form-data="uploadData" @on-success="uploadLicenseSuccess"
  36. @on-error="uploadError" :custom-btn="true" max-count="1" class="diy-upload">
  37. <image slot="addBtn" class="license-img" src="../../static/images/license-img.png"></image>
  38. </u-upload>
  39. <view class="license-text"> 营业执照</view>
  40. </view>
  41. </u-cell-item>
  42. <u-field label="法人姓名" required placeholder="请输入法人姓名" label-width="180" v-model="shopInfo.duty"></u-field>
  43. <u-cell-item title="所在城市" required @click="regionShow = true">
  44. <text v-show="shopInfo.companyAddressProvince">{{shopInfo.companyAddressProvince}}-{{shopInfo.companyAddressCity}}-{{shopInfo.companyAddressDistrict}}</text>
  45. </u-cell-item>
  46. <!-- <u-form-item label="联系方式" prop="contactTel"> -->
  47. <u-field label="联系方式" required :error-message="errorMessage1" placeholder="请输入联系方式" label-width="180" v-model="shopInfo.contactTel"></u-field>
  48. <!-- <input type="number" placeholder="请输入联系方式" label-width="180" v-model="shopInfo.contactTel" /> -->
  49. <!-- </u-form-item> -->
  50. <u-field label="收款人姓名" required placeholder="请输入收款人姓名" label-width="180" v-model="shopInfo.collectionName"></u-field>
  51. <u-field label="户名" required placeholder="请输入户名" label-width="180" v-model="shopInfo.bankAccountName"></u-field>
  52. <u-field label="银行名称" required placeholder="请输入银行名称" label-width="180" v-model="shopInfo.bankAllName"></u-field>
  53. <u-field label="银行卡号" required :error-message="errorMessage2" placeholder="请输入银行卡号" label-width="180" v-model="shopInfo.bankNumber"></u-field>
  54. </u-form>
  55. </u-cell-group>
  56. <view class="form-handle">
  57. <u-button type="success" shape="circle" :ripple="true" @click="submitData" class="handle-custom">提交</u-button>
  58. </view>
  59. <u-picker mode="region" v-model="regionShow" @confirm="setRegion"></u-picker>
  60. <u-top-tips ref="uTips"></u-top-tips>
  61. </view>
  62. </template>
  63. <script>
  64. const NET = require('@/utils/request')
  65. const API = require('@/config/api')
  66. export default {
  67. data() {
  68. return {
  69. cWidth: 0,
  70. type: '',
  71. shopInfo: {
  72. name: '',
  73. logo: '',
  74. idCardCopyFilePath: '',
  75. idCardNationalFilePath: '',
  76. businessLicenseCopyFilePath: '',
  77. duty: '',
  78. companyAddressProvince: '',
  79. companyAddressCity: '',
  80. companyAddressDistrict: '',
  81. contactTel: null,
  82. collectionName: '',
  83. bankAccountName: '',
  84. bankAllName: '',
  85. bankNumber: null,
  86. },
  87. regionShow: false,
  88. uploadData: {
  89. folderId: 0,
  90. },
  91. uploadUrl: '',
  92. fileList: [],
  93. defaultList1: [],
  94. defaultList2: [],
  95. defaultList3: [],
  96. defaultList4: [],
  97. defaultList5: [],
  98. rules: {
  99. name: [
  100. {
  101. required: true,
  102. message: '请输入姓名',
  103. // 可以单个或者同时写两个触发验证方式
  104. trigger: 'blur',
  105. }
  106. ]
  107. },
  108. errorMessage1: '',
  109. errorMessage2: ''
  110. }
  111. },
  112. // 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
  113. onReady() {
  114. // this.$refs.shopInfo.setRules(this.rules);
  115. },
  116. onLoad(options) {
  117. this.cWidth = (uni.upx2px(750) - 40) / 2;
  118. this.uploadUrl = API.uploadFile
  119. this.type = options.type
  120. if (options.type == 'edit') {
  121. NET.request(API.getShopRegisterInfo, {}, 'GET').then(res => {
  122. this.shopInfo = {
  123. name: res.data.name,
  124. logo: res.data.logo,
  125. idCardCopyFilePath: res.data.idCardCopyFilePath,
  126. idCardNationalFilePath: res.data.idCardNationalFilePath,
  127. businessLicenseCopyFilePath: res.data.businessLicenseCopyFilePath,
  128. duty: res.data.duty,
  129. companyAddressProvince: res.data.companyAddressProvince,
  130. companyAddressCity: res.data.companyAddressCity,
  131. companyAddressDistrict: res.data.companyAddressDistrict,
  132. contactTel: res.data.contactTel,
  133. collectionName: res.data.collectionName,
  134. bankAccountName: res.data.bankAccountName,
  135. bankAllName: res.data.bankAllName,
  136. bankNumber: res.data.bankNumber,
  137. }
  138. this.fileList = res.data.storeImgUrl.split(',')
  139. this.defaultList1 = [{
  140. url: res.data.logo,
  141. // url: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1603877862802&di=e1d4201e637fcd3e21a9b52fbfc1b771&imgtype=0&src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F202005%2F25%2F20200525131219_ntnpg.thumb.400_0.jpeg"
  142. }]
  143. this.defaultList2 = res.data.storeImgUrl.split(',').map(site => {
  144. return {
  145. url: site
  146. }
  147. })
  148. this.defaultList3 = [{
  149. url: res.data.idCardCopyFilePath
  150. }]
  151. this.defaultList4 = [{
  152. url: res.data.idCardNationalFilePath
  153. }]
  154. this.defaultList5 = [{
  155. url: res.data.businessLicenseCopyFilePath
  156. }]
  157. }).catch(res => {
  158. this.$refs.uTips.show({
  159. title: '获取注册信息失败',
  160. type: 'warning',
  161. })
  162. })
  163. }
  164. },
  165. methods: {
  166. // logo上传成功回调
  167. logoUploadSuccess(res, index, lists, name) {
  168. this.shopInfo.logo = res.data.url
  169. this.$refs.uTips.show({
  170. title: 'logo上传成功',
  171. type: 'success',
  172. })
  173. return true
  174. },
  175. // 文件上传成功回调
  176. uploadSuccess(res, index, lists, name) {
  177. this.fileList.push(res.data.url)
  178. this.$refs.uTips.show({
  179. title: '文件上传成功',
  180. type: 'success',
  181. })
  182. return true
  183. },
  184. // 身份证正面上传成功回调
  185. uploadIdCardSuccess1(res, index, lists, name) {
  186. this.shopInfo.idCardCopyFilePath = res.data.url
  187. this.$refs.uTips.show({
  188. title: '身份证正面照片上传成功',
  189. type: 'success',
  190. })
  191. return true
  192. },
  193. // 身份证反面上传成功回调
  194. uploadIdCardSuccess2(res, index, lists, name) {
  195. this.shopInfo.idCardNationalFilePath = res.data.url
  196. this.$refs.uTips.show({
  197. title: '身份证反面照片上传成功',
  198. type: 'success',
  199. })
  200. return true
  201. },
  202. // 营业执照上传成功回调
  203. uploadLicenseSuccess(res, index, lists, name) {
  204. this.shopInfo.businessLicenseCopyFilePath = res.data.url
  205. this.$refs.uTips.show({
  206. title: '营业执照照片上传成功',
  207. type: 'success',
  208. })
  209. return true
  210. },
  211. // 文件上传失败回调
  212. uploadError(res, index, lists, name) {
  213. this.$refs.uTips.show({
  214. title: '文件上传失败',
  215. type: 'warning',
  216. })
  217. },
  218. // 移除文件回调
  219. uploadRemove(index, lists, name) {
  220. this.fileList.splice(index, 1)
  221. },
  222. // 设置地址
  223. setRegion(data) {
  224. this.shopInfo.companyAddressProvince = data.province.label
  225. this.shopInfo.companyAddressCity = data.city.label
  226. this.shopInfo.companyAddressDistrict = data.area.label
  227. },
  228. // 提交
  229. submitData() {
  230. debugger
  231. let required = true
  232. for (let key in this.shopInfo) {
  233. if (!this.shopInfo[key]) {
  234. required = false
  235. }
  236. }
  237. if (!required) {
  238. this.$refs.uTips.show({
  239. title: '请填写必填项',
  240. type: 'warning',
  241. })
  242. return false
  243. }
  244. if (!Number(this.shopInfo.contactTel)) {
  245. this.errorMessage1 = '请输入数字'
  246. return
  247. } else {
  248. this.errorMessage1 = ''
  249. }
  250. if (!Number(this.shopInfo.bankNumber)) {
  251. this.errorMessage2 = '请输入数字'
  252. return
  253. } else {
  254. this.errorMessage2 = ''
  255. }
  256. if (!this.fileList.length) {
  257. this.$refs.uTips.show({
  258. title: '请上传店铺主页图',
  259. type: 'warning',
  260. })
  261. return false
  262. }
  263. if (this.type == 'edit') {
  264. NET.request(API.editShopRegisterInfo, {
  265. ...this.shopInfo,
  266. address: this.shopInfo.companyAddressProvince + '-' + this.shopInfo.companyAddressCity + '-' + this.shopInfo.companyAddressDistrict,
  267. companyAddress: this.shopInfo.companyAddressProvince + '-' + this.shopInfo.companyAddressCity + '-' + this.shopInfo
  268. .companyAddressDistrict,
  269. storeImgUrl: this.fileList.join(',')
  270. }, 'PUT').then(res => {
  271. this.$refs.uTips.show({
  272. title: '编辑成功',
  273. type: 'success',
  274. })
  275. setTimeout(() => {
  276. uni.redirectTo({
  277. url: '/pages/index/registerState'
  278. });
  279. }, 1000)
  280. }).catch(res => {
  281. this.$refs.uTips.show({
  282. title: '编辑失败',
  283. type: 'warning',
  284. })
  285. })
  286. } else {
  287. NET.request(API.submitShopRegisterInfo, {
  288. ...this.shopInfo,
  289. address: this.shopInfo.companyAddressProvince + '-' + this.shopInfo.companyAddressCity + '-' + this.shopInfo.companyAddressDistrict,
  290. companyAddress: this.shopInfo.companyAddressProvince + '-' + this.shopInfo.companyAddressCity + '-' + this.shopInfo
  291. .companyAddressDistrict,
  292. storeImgUrl: this.fileList.join(',')
  293. }, 'POST').then(res => {
  294. this.$refs.uTips.show({
  295. title: '注册成功',
  296. type: 'success',
  297. })
  298. setTimeout(() => {
  299. uni.redirectTo({
  300. url: '/pages/index/registerState'
  301. });
  302. }, 1000)
  303. }).catch(res => {
  304. this.$refs.uTips.show({
  305. title: '注册失败',
  306. type: 'warning',
  307. })
  308. })
  309. }
  310. },
  311. },
  312. }
  313. </script>
  314. <style lang="less" scoped>
  315. page {
  316. width: 100%;
  317. height: 100%;
  318. }
  319. .container {
  320. width: 100%;
  321. height: 100%;
  322. float: left;
  323. overflow-y: auto;
  324. .form-info {
  325. width: 100%;
  326. float: left;
  327. /deep/.u-label-text {
  328. color: #333333;
  329. line-height: 40px;
  330. font-size: 15px;
  331. }
  332. /deep/.u-cell_title {
  333. color: #333333;
  334. line-height: 40px;
  335. font-size: 15px;
  336. }
  337. .id-card-box {
  338. display: flex;
  339. .id-card {
  340. height: 140px;
  341. margin-right: 10px;
  342. box-sizing: border-box;
  343. padding-top: 110px;
  344. background-color: #51A539;
  345. background-size: 100% 110px;
  346. background-position: center top;
  347. background-repeat: no-repeat;
  348. border-radius: 6px;
  349. font-size: 15px;
  350. font-family: PingFang SC;
  351. color: #FFFFFF;
  352. line-height: 30px;
  353. text-align: center;
  354. }
  355. .card-img1 {
  356. background-image: url(@/static/images/card-img1.png);
  357. }
  358. .card-img2 {
  359. background-image: url(@/static/images/card-img2.png);
  360. }
  361. /deep/.u-list-item {
  362. width: 100% !important;
  363. height: 110px !important;
  364. }
  365. }
  366. .license-box {
  367. width: 100%;
  368. height: 175px;
  369. position: relative;
  370. .diy-upload {
  371. width: 100%;
  372. height: 145px;
  373. position: absolute;
  374. }
  375. .license-img {
  376. width: 100%;
  377. height: 145px;
  378. position: absolute;
  379. }
  380. /deep/.u-list-item {
  381. width: 100% !important;
  382. height: 145px !important;
  383. }
  384. }
  385. .license-text {
  386. width: 100%;
  387. height: 30px;
  388. margin-top: 5px;
  389. font-size: 15px;
  390. font-family: PingFang SC;
  391. color: #656565;
  392. line-height: 30px;
  393. text-align: center;
  394. position: relative;
  395. top: 145px;
  396. }
  397. }
  398. .form-handle {
  399. width: calc(100% - 30px);
  400. float: left;
  401. height: 40px;
  402. margin: 30px 15px 20px 15px;
  403. .handle-custom {
  404. background-color: #51A539;
  405. /deep/button {
  406. background-color: #56a83a;
  407. }
  408. /deep/.u-btn--success--disabled {
  409. background-color: #74bd60 !important;
  410. }
  411. }
  412. // /deep/.u-btn--success--disabled {
  413. // background-color: #999999 !important;
  414. // }
  415. }
  416. }
  417. .all-width {
  418. /deep/.u-cell_title {
  419. width: 100% !important;
  420. }
  421. }
  422. </style>