register.vue 13 KB

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