register.vue 12 KB

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