register_2.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <view>
  3. <u-card :border="false" padding="30" box-shadow="0px 1px 10px rgba(0,0,0,0.2)" border-radius="20" :show-foot="false">
  4. <view slot="head">
  5. <view class="u-flex">
  6. <view style="width: 8rpx;height: 34rpx;background: #0292FD;margin-right:20rpx;"></view>
  7. {{$t('register_2.cardtitle')}}
  8. </view>
  9. </view>
  10. <view slot="body">
  11. <u-form :model="form" ref="uForm">
  12. <u-form-item prop="store">
  13. <view style="margin-right: 10rpx;">
  14. <u-icon name="home" size="36"></u-icon>
  15. </view>
  16. <view style="margin-right: 10rpx;">{{$t('register_2.storeText')}}</view>
  17. <u-input v-model="form.store" :placeholder="this.$t('register_2.store')" />
  18. </u-form-item>
  19. <u-form-item prop="company">
  20. <view style="margin-right: 10rpx;">
  21. <u-icon name="home" size="36"></u-icon>
  22. </view>
  23. <view style="margin-right: 10rpx;">{{$t('register_2.companyText')}}</view>
  24. <u-input v-model="form.company" :placeholder="this.$t('register_2.company')" :disabled="true" />
  25. <view style="font-size: 16rpx;color: red;">
  26. {{$t('register_2.notwrite')}}
  27. </view>
  28. </u-form-item>
  29. <u-form-item prop="name">
  30. <view style="margin-right: 10rpx;">
  31. <u-icon name="account" size="36"></u-icon>
  32. </view>
  33. <u-input v-model="form.name" placeholder="this.$t('register_2.name')" />
  34. </u-form-item>
  35. <u-form-item prop="phone">
  36. <view style="margin-right: 10rpx;">
  37. <u-icon name="phone" size="36"></u-icon>
  38. </view>
  39. <u-input v-model="form.phone" :placeholder="this.$t('register_2.phone')" type="number" />
  40. </u-form-item>
  41. <u-form-item prop="code">
  42. <view style="margin-right: 10rpx;">
  43. <u-icon name="lock" size="36"></u-icon>
  44. </view>
  45. <u-input v-model="form.code" placeholder="请输入验证码" type="number" maxlength="6"/>
  46. <view class="" slot="right">
  47. <u-button size="mini" type="primary" @click="getCode" shape="circle" :loading="codeLoading">{{codeText}}</u-button>
  48. </view>
  49. </u-form-item>
  50. <u-form-item prop="region">
  51. <view style="margin-right: 10rpx;">
  52. <u-icon name="map" size="36"></u-icon>
  53. </view>
  54. <u-input placeholder="点击选择省市区" v-model="form.region" :disabled="true" @click="inMap"></u-input>
  55. <view class="" slot="right">
  56. <u-icon name="arrow-right" color="#666666" size="36"></u-icon>
  57. </view>
  58. </u-form-item>
  59. <u-form-item prop="addressInfo">
  60. <view style="margin-right: 10rpx;">
  61. <u-icon name="map" size="36"></u-icon>
  62. </view>
  63. <u-input placeholder="点击选择详细地址" v-model="form.addressInfo" :disabled="true" @click="inMap"></u-input>
  64. <view class="" slot="right">
  65. <u-icon name="arrow-right" color="#666666" size="36"></u-icon>
  66. </view>
  67. </u-form-item>
  68. </u-form>
  69. <u-verification-code ref="uCode" @change="codeChange"></u-verification-code>
  70. </view>
  71. </u-card>
  72. <view style="margin: 30rpx;">
  73. <u-button @click="nextStep" type="primary">下一步</u-button>
  74. </view>
  75. <u-modal v-model="modelshow" :content="modelcontent" title="温馨提示"></u-modal>
  76. </view>
  77. </template>
  78. <script>
  79. import {
  80. request
  81. } from '../../common/request/request'
  82. require("promise.prototype.finally").shim()
  83. export default {
  84. data() {
  85. return {
  86. codeText: '',
  87. form: {
  88. store: '',
  89. company: '',
  90. name: "",
  91. phone: "",
  92. code: '',
  93. region: '',
  94. latitude: '',
  95. longitude: '',
  96. province: "",
  97. city: "",
  98. district: "",
  99. addressInfo: ""
  100. },
  101. rules: {
  102. store: [{
  103. required: true,
  104. message: '请输入门店名称',
  105. trigger: 'blur,change'
  106. },
  107. {
  108. pattern: /^[\u4e00-\u9fa5_a-zA-Z()()0-9]+$/g,
  109. // 正则检验前先将值转为字符串
  110. transform(value) {
  111. return String(value);
  112. },
  113. message: '门店名称必须为中文或英语、数字',
  114. // 触发器可以同时用blur和change,二者之间用英文逗号隔开
  115. trigger: ['change', 'blur'],
  116. },
  117. ],
  118. company: [{
  119. required: true,
  120. message: '请输入公司名称',
  121. trigger: 'blur,change'
  122. }],
  123. name: [{
  124. required: true,
  125. message: '请输入联系人',
  126. trigger: 'blur,change'
  127. }, {
  128. min: 2,
  129. message: '姓名长度至少在2个字符以上',
  130. trigger: ['change', 'blur'],
  131. },
  132. {
  133. // 此为同步验证,可以直接返回true或者false,如果是异步验证,稍微不同,见下方说明
  134. pattern: /^[\u4e00-\u9fa5_a-zA-Z ]+$/g,
  135. // 正则检验前先将值转为字符串
  136. transform(value) {
  137. return String(value);
  138. },
  139. message: '姓名必须为中文或英文',
  140. // 触发器可以同时用blur和change,二者之间用英文逗号隔开
  141. trigger: ['change', 'blur'],
  142. }
  143. ],
  144. phone: [{
  145. required: true,
  146. message: '请输入联系电话',
  147. trigger: 'blur,change'
  148. },
  149. {
  150. validator: (rule, value, callback) => {
  151. // 调用uView自带的js验证规则,详见:https://www.uviewui.com/js/test.html
  152. return this.$u.test.mobile(value);
  153. },
  154. message: '手机号码不正确',
  155. // 触发器可以同时用blur和change,二者之间用英文逗号隔开
  156. trigger: ['change', 'blur'],
  157. }
  158. ],
  159. code: [{
  160. required: true,
  161. message: '请输入验证码',
  162. trigger: 'blur,change'
  163. },
  164. {
  165. min: 6,
  166. max: 6,
  167. message: '验证码为6位数',
  168. trigger: 'change',
  169. },
  170. {
  171. type: 'number',
  172. message: '验证码只能为数字',
  173. trigger: ['change', 'blur'],
  174. }
  175. ],
  176. region: [{
  177. required: true,
  178. message: '请选择地区',
  179. trigger: 'change',
  180. }],
  181. addressInfo: [{
  182. required: true,
  183. message: '请选择地区',
  184. trigger: 'change',
  185. }],
  186. },
  187. dataUrl: "",
  188. codeLoading: false,
  189. modelshow: false,
  190. modelcontent: "如果店名和联系人与营业执照不一致,请重新上传清晰度更高的营业执照。",
  191. lonlatData:'',
  192. bd09:false
  193. };
  194. },
  195. created() {
  196. uni.$on('licenseData', (data) => {
  197. if (data.company.words != "无") {
  198. this.form.store = data.company.words
  199. }
  200. this.form.company = data.company.words
  201. if (data.person.words != "无") {
  202. this.form.name = data.person.words
  203. }
  204. })
  205. uni.$on('addressData', (data) => {
  206. if(data.latitude&&data.longitude){
  207. request({
  208. url: '/baseReq/getBaiDuMapMsg',
  209. method: 'get',
  210. params: {
  211. "longitude": data.longitude,
  212. "latitude": data.latitude
  213. },
  214. }).then(res => {
  215. if (res.data.code == 0) {
  216. this.lonlatData=res.data.data.result
  217. this.bd09=true
  218. }
  219. if (res.data.code == 500) {
  220. this.$u.toast(res.data.msg);
  221. }
  222. }).catch(err => {
  223. }).finally(() => {
  224. })
  225. }
  226. this.address = data.address
  227. this.form.region = this.address.province + "-" + this.address.city + "-" + this.address.district
  228. this.form.addressInfo = this.address.addressInfo
  229. this.form.province = this.address.province;
  230. this.form.city = this.address.city;
  231. this.form.district = this.address.district;
  232. })
  233. uni.$on('dataUrl', (data) => {
  234. this.dataUrl = data
  235. })
  236. uni.getSystemInfo({
  237. success: res => {
  238. this.SystemInfo = res
  239. }
  240. });
  241. if (this.SystemInfo.platform == 'ios') {
  242. uni.showModal({
  243. title: "温馨提示",
  244. content: "如果店名和联系人与营业执照不一致,请重新上传清晰度更高的营业执照。",
  245. confirmText: "确认",
  246. showCancel: false
  247. })
  248. } else {
  249. this.modelshow= true
  250. }
  251. },
  252. methods: {
  253. nextStep() {
  254. this.form.latitude = this.lonlatData.y
  255. this.form.longitude = this.lonlatData.x
  256. this.$refs.uForm.validate(valid => {
  257. if (valid) {
  258. if(!this.bd09){
  259. this.$u.toast('正在转换坐标,请稍候');
  260. return
  261. }
  262. this.$u.route({
  263. url: 'pages/login/register_3',
  264. })
  265. uni.$emit("formData", {
  266. formData: this.form,
  267. dataUrl: this.dataUrl
  268. })
  269. } else {
  270. }
  271. });
  272. },
  273. codeChange(text) {
  274. this.codeText = text;
  275. },
  276. getCode() {
  277. if (this.$u.test.mobile(this.form.phone)) {
  278. if (this.$refs.uCode.canGetCode) {
  279. this.codeLoading = true
  280. request({
  281. url: '/sailun/appStoreBasicInfo/sendCode',
  282. method: 'post',
  283. data: {
  284. "phoneNumber": parseInt(this.form.phone),
  285. "opreaType": "0"
  286. },
  287. }).then(res => {
  288. if (res.data.code == 0) {
  289. this.$refs.uCode.start();
  290. }
  291. if (res.data.code == 500) {
  292. this.$u.toast(res.data.msg);
  293. }
  294. }).catch(err => {
  295. }).finally(() => {
  296. this.codeLoading = false
  297. // 通知验证码组件内部开始倒计时
  298. })
  299. } else {
  300. this.$u.toast('倒计时结束后再发送');
  301. }
  302. } else {
  303. this.$u.toast('请输入手机号');
  304. }
  305. },
  306. inMap() {
  307. this.bd09=false
  308. this.$u.route({
  309. url: 'pages/login/register_map'
  310. })
  311. }
  312. },
  313. onReady() {
  314. this.$refs.uForm.setRules(this.rules);
  315. }
  316. }
  317. </script>
  318. <style lang="scss" scoped>
  319. .label-style {
  320. font-size: 10rpx;
  321. color: #F2F2F2;
  322. }
  323. </style>