register.vue 13 KB

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