storeInformation.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <template>
  2. <view class="container">
  3. <view class="top-box">
  4. 为了方便我们与您尽快联系达成合作,请如实填写以下资料,谢谢您的支持与配合
  5. </view>
  6. <u-form :model="storeInfo" ref="uForm" labelPosition="left" :rules="rules" labelWidth="80">
  7. <view class="content-box">
  8. <view class="content-item">
  9. <u-form-item prop="legalRepresentativeName" required label="姓名" right>
  10. <view class="item-r">
  11. <u--input placeholder="请输入负责人名称" border="surround" v-model="storeInfo.legalRepresentativeName"></u--input>
  12. </view>
  13. </u-form-item>
  14. </view>
  15. <view class="content-item">
  16. <u-form-item prop="mobileNumber" required label="手机号码" right>
  17. <view class="item-r">
  18. <u--input placeholder="请输入手机号码" border="surround" v-model="storeInfo.mobileNumber"></u--input>
  19. </view>
  20. </u-form-item>
  21. </view>
  22. <view class="content-item">
  23. <u-form-item prop="email" required label="电子邮箱" right>
  24. <view class="item-r">
  25. <u--input placeholder="请输入您的邮箱" border="surround" v-model="storeInfo.email"></u--input>
  26. </view>
  27. </u-form-item>
  28. </view>
  29. </view>
  30. <view class="content-box">
  31. <view class="content-item">
  32. <u-form-item prop="storeName" required label="店铺名称" right>
  33. <view class="item-r">
  34. <u--input placeholder="请输入店铺名称" border="surround" v-model="storeInfo.storeName"></u--input>
  35. </view>
  36. </u-form-item>
  37. </view>
  38. <view class="content-item">
  39. <u-form-item prop="storeAddress" required label="所在地区" right>
  40. <view class="item-r">
  41. <u--input placeholder="请选择所在地区" border="surround" v-model="storeInfo.storeAddress"
  42. @focus="handlerChange"></u--input>
  43. </view>
  44. <view class="icon-right-box">
  45. <u-icon name="arrow-right" color="#c5c5c5" size="20"></u-icon>
  46. </view>
  47. </u-form-item>
  48. </view>
  49. <view class="content-item">
  50. <u-form-item prop="storeAddressDetail" required label="详细地址" right>
  51. <view class="item-r">
  52. <u--input placeholder="请输入门店详细地址" border="surround" v-model="storeInfo.storeAddressDetail"></u--input>
  53. </view>
  54. </u-form-item>
  55. </view>
  56. </view>
  57. <view class="content-box">
  58. <u-form-item prop="storeImage">
  59. <imgs-upload @update="fileList" :value="1"></imgs-upload>
  60. <p class="upload-text">店铺门面图(需要包含完整牌匾)</p>
  61. </u-form-item>
  62. </view>
  63. <view class="content-box">
  64. <u-form-item prop="storeInnerImage">
  65. <imgs-upload @update="fileList" :value="2"></imgs-upload>
  66. <p class="upload-text">店内真实环境图</p>
  67. </u-form-item>
  68. </view>
  69. </u-form>
  70. <button class="btn" @click="handlerSkipNext">下一步</button>
  71. <!-- 地区 -->
  72. <u-picker :show="show" ref="uPicker" :columns="cityList" @confirm="confirm" @change="changeHandler"
  73. @cancel="show = false"></u-picker>
  74. </view>
  75. </template>
  76. <script>
  77. import ImgsUpload from './components/ImgsUpload.vue';
  78. // 导入城市js文件
  79. import cityData from '@/utils/city';
  80. export default {
  81. components: {
  82. ImgsUpload,
  83. },
  84. data() {
  85. return {
  86. storeInfo: {
  87. storeAddress: '',
  88. storeAddressDetail: '',
  89. legalRepresentativeName: '',
  90. mobileNumber: '',
  91. storeName: '',
  92. storeImage: '',
  93. storeInnerImage: '',
  94. email: ""
  95. },
  96. rules: {
  97. legalRepresentativeName: {
  98. type: 'string',
  99. required: true,
  100. message: '请输入负责人名称',
  101. trigger: ['blur', 'change'],
  102. },
  103. storeName: {
  104. type: 'string',
  105. required: true,
  106. message: '请输入店铺名',
  107. trigger: ['blur', 'change'],
  108. },
  109. storeAddressDetail: {
  110. type: 'string',
  111. required: true,
  112. message: '请输入详细地址',
  113. trigger: ['blur', 'change'],
  114. },
  115. mobileNumber: [{
  116. required: true,
  117. message: '请输入手机号码',
  118. trigger: ['blur', 'change'],
  119. },
  120. {
  121. validator: (rule, value, callback) => {
  122. return uni.$u.test.mobile(value);
  123. },
  124. message: '手机号码不正确',
  125. trigger: ['change', 'blur'],
  126. },
  127. ],
  128. email: [{
  129. required: true,
  130. message: '请输入您的邮箱',
  131. trigger: ['blur', 'change'],
  132. },
  133. {
  134. validator: (rule, value, callback) => {
  135. return uni.$u.test.email(value);
  136. },
  137. message: '您输入的邮箱不正确',
  138. trigger: ['change', 'blur'],
  139. },
  140. ],
  141. storeAddress: [{
  142. required: true,
  143. message: '请选择所在地区',
  144. trigger: ['change'],
  145. }, ],
  146. },
  147. show: false, //显示选择器
  148. // 打开选择器显示默认城市
  149. cityList: [],
  150. cityLevel1: [],
  151. cityLevel2: [],
  152. cityLevel3: [],
  153. };
  154. },
  155. onReady() {
  156. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  157. this.$refs.uForm.setRules(this.rules);
  158. },
  159. onShow() {
  160. this.initCityData();
  161. },
  162. methods: {
  163. initCityData() {
  164. // 遍历城市js
  165. cityData.forEach((item1, index1) => {
  166. let temp2 = [];
  167. this.cityLevel1.push(item1.provinceName);
  168. let temp4 = [];
  169. let temp3 = [];
  170. // 遍历市
  171. item1.cities.forEach((item2, index2) => {
  172. temp2.push(item2.cityName);
  173. // 遍历区
  174. item2.counties.forEach((item3, index3) => {
  175. temp3.push(item3.countyName);
  176. });
  177. temp4[index2] = temp3;
  178. temp3 = [];
  179. });
  180. this.cityLevel3[index1] = temp4;
  181. this.cityLevel2[index1] = temp2;
  182. });
  183. // 选择器默认城市
  184. this.cityList.push(this.cityLevel1, this.cityLevel2[0], this.cityLevel3[0][0]);
  185. },
  186. // 选中时执行
  187. changeHandler(e) {
  188. const {
  189. columnIndex,
  190. index,
  191. indexs,
  192. value,
  193. values,
  194. // 微信小程序无法将picker实例传出来,只能通过ref操作
  195. picker = this.$refs.uPicker,
  196. } = e;
  197. if (columnIndex === 0) {
  198. // 选择第一列数据时 设置第二列关联数据
  199. picker.setColumnValues(1, this.cityLevel2[index]);
  200. // 设置第三列关联数据
  201. picker.setColumnValues(2, this.cityLevel3[index][columnIndex]);
  202. } else if (columnIndex === 1) {
  203. // 选择第二列数据时 设置第三列关联数据
  204. picker.setColumnValues(2, this.cityLevel3[indexs[0]][index]);
  205. }
  206. },
  207. // 单击确认按钮时执行
  208. confirm(e) {
  209. this.storeInfo.storeAddress = e.value.join('');
  210. // 隐藏城市选择器
  211. this.show = false;
  212. },
  213. handlerChange() {
  214. this.show = true;
  215. },
  216. handlerSkipNext() {
  217. this.$refs.uForm.validate().then(res => {
  218. this.$store.commit('SET_STOREINFO', this.storeInfo);
  219. setTimeout(() => {
  220. uni.navigateTo({
  221. url: '/pages/merchant/mine/openStore/corporateInformation',
  222. });
  223. }, 1500);
  224. });
  225. },
  226. // 图片
  227. fileList(val, data) {
  228. if (data == 1) {
  229. this.storeInfo.storeImage = val[0];
  230. } else if (data == 2) {
  231. this.storeInfo.storeInnerImage = val[0];
  232. }
  233. },
  234. },
  235. };
  236. </script>
  237. <style lang="scss" scoped>
  238. .container {
  239. background-color: #f7f7f7 !important;
  240. padding-bottom: 40rpx;
  241. .top-box {
  242. color: #666666;
  243. font-size: 26rpx;
  244. text-align: center;
  245. padding: 20rpx 40rpx;
  246. background-color: #fff;
  247. }
  248. .content-box {
  249. padding: 20rpx 40rpx;
  250. background-color: #fff;
  251. margin: 10rpx 0;
  252. .content-item {
  253. position: relative;
  254. .item-r {
  255. background-color: #f7f7f7;
  256. border-radius: 20rpx;
  257. display: flex;
  258. .data_select {
  259. width: 90%;
  260. }
  261. ::v-deep .u-form-item {
  262. width: 100%;
  263. }
  264. ::v-deep .u-form-item__body {
  265. padding: 0;
  266. }
  267. }
  268. .icon-right-box {
  269. position: absolute;
  270. right: 15rpx;
  271. top: 40rpx;
  272. }
  273. }
  274. .upload-text {
  275. text-align: center;
  276. color: #666666;
  277. font-size: 28rpx;
  278. margin-top: 20rpx;
  279. }
  280. }
  281. .btn {
  282. background-color: #5992bb !important;
  283. color: #fff;
  284. font-size: 32rpx;
  285. border-radius: 40rpx;
  286. margin-top: 100rpx;
  287. margin-bottom: 100rpx;
  288. width: 95%;
  289. }
  290. }
  291. ::v-deep .uni-select {
  292. border: none !important;
  293. }
  294. ::v-deep .uni-select__input-placeholder {
  295. font-size: 28rpx !important;
  296. color: #cbced4 !important;
  297. }
  298. </style>