register_2.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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. 基本信息
  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. <u-input v-model="form.store" placeholder="请输入门店名称" />
  17. </u-form-item>
  18. <u-form-item prop="company">
  19. <view style="margin-right: 10rpx;">
  20. <u-icon name="home" size="36"></u-icon>
  21. </view>
  22. <u-input v-model="form.company" placeholder="请输入公司名称" :disabled="true" />
  23. </u-form-item>
  24. <u-form-item prop="name">
  25. <view style="margin-right: 10rpx;">
  26. <u-icon name="account" size="36"></u-icon>
  27. </view>
  28. <u-input v-model="form.name" placeholder="请输入联系人" />
  29. </u-form-item>
  30. <u-form-item prop="phone">
  31. <view style="margin-right: 10rpx;">
  32. <u-icon name="phone" size="36"></u-icon>
  33. </view>
  34. <u-input v-model="form.phone" placeholder="请输入联系电话" type="number" />
  35. </u-form-item>
  36. <u-form-item prop="code">
  37. <view style="margin-right: 10rpx;">
  38. <u-icon name="lock" size="36"></u-icon>
  39. </view>
  40. <u-input v-model="form.code" placeholder="请输入验证码" type="number" />
  41. <view class="" slot="right">
  42. <u-button size="mini" type="primary" @click="getCode" shape="circle" :loading="codeLoading">{{codeText}}</u-button>
  43. </view>
  44. </u-form-item>
  45. <!-- <u-form-item prop="region">
  46. <view style="margin-right: 10rpx;">
  47. <u-icon name="map" size="36"></u-icon>
  48. </view>
  49. <u-input :select-open="pickerShow" v-model="form.region" placeholder="点击选择省市区" @click="pickerShow = true"
  50. :disabled="true"></u-input>
  51. <view class="" slot="right">
  52. <u-icon name="arrow-right" color="#666666" size="36"></u-icon>
  53. </view>
  54. </u-form-item> -->
  55. <u-form-item prop="region">
  56. <view style="margin-right: 10rpx;">
  57. <u-icon name="map" size="36"></u-icon>
  58. </view>
  59. <u-input placeholder="点击选择省市区" v-model="form.region" :disabled="true" @click="inMap"></u-input>
  60. <view class="" slot="right">
  61. <u-icon name="arrow-right" color="#666666" size="36"></u-icon>
  62. </view>
  63. </u-form-item>
  64. <u-form-item prop="addressInfo">
  65. <view style="margin-right: 10rpx;">
  66. <u-icon name="map" size="36"></u-icon>
  67. </view>
  68. <u-input placeholder="点击选择详细地址" v-model="form.addressInfo" :disabled="true" @click="inMap"></u-input>
  69. <view class="" slot="right">
  70. <u-icon name="arrow-right" color="#666666" size="36"></u-icon>
  71. </view>
  72. </u-form-item>
  73. </u-form>
  74. <u-verification-code ref="uCode" @change="codeChange"></u-verification-code>
  75. <u-picker mode="region" v-model="pickerShow" @confirm="regionConfirm" :default-region="defaultRegion"></u-picker>
  76. </view>
  77. </u-card>
  78. <view style="margin: 30rpx;">
  79. <u-button @click="nextStep" type="primary">下一步</u-button>
  80. </view>
  81. <u-modal v-model="modelshow" :content="modelcontent" title="温馨提示"></u-modal>
  82. </view>
  83. </template>
  84. <script>
  85. import permision from "@/js_sdk/wa-permission/permission.js"
  86. import {
  87. request
  88. } from '../../common/request/request'
  89. require("promise.prototype.finally").shim()
  90. export default {
  91. data() {
  92. return {
  93. codeText: '',
  94. pickerShow: false,
  95. defaultRegion: [],
  96. form: {
  97. store: '',
  98. company: '',
  99. name: "",
  100. phone: "",
  101. code: '',
  102. region: '',
  103. latitude: '',
  104. longitude: '',
  105. province: "",
  106. city: "",
  107. district: "",
  108. addressInfo: "",
  109. },
  110. rules: {
  111. store: [{
  112. required: true,
  113. message: '请输入门店名称',
  114. trigger: 'blur,change'
  115. },
  116. {
  117. // 此为同步验证,可以直接返回true或者false,如果是异步验证,稍微不同,见下方说明
  118. validator: (rule, value, callback) => {
  119. // 调用uView自带的js验证规则,详见:https://www.uviewui.com/js/test.html
  120. return this.$u.test.chinese(value);
  121. },
  122. message: '门店名称必须为中文',
  123. // 触发器可以同时用blur和change,二者之间用英文逗号隔开
  124. trigger: ['change','blur'],
  125. },
  126. ],
  127. company: [{
  128. required: true,
  129. message: '请输入公司名称',
  130. trigger: 'blur,change'
  131. }],
  132. name: [{
  133. required: true,
  134. message: '请输入联系人',
  135. trigger: 'blur,change'
  136. },{
  137. min: 3,
  138. max: 5,
  139. message: '姓名长度在3到5个字符',
  140. trigger: ['change','blur'],
  141. },
  142. {
  143. // 此为同步验证,可以直接返回true或者false,如果是异步验证,稍微不同,见下方说明
  144. validator: (rule, value, callback) => {
  145. // 调用uView自带的js验证规则,详见:https://www.uviewui.com/js/test.html
  146. return this.$u.test.chinese(value);
  147. },
  148. message: '姓名必须为中文',
  149. // 触发器可以同时用blur和change,二者之间用英文逗号隔开
  150. trigger: ['change','blur'],
  151. }],
  152. phone: [{
  153. required: true,
  154. message: '请输入联系电话',
  155. trigger: 'blur,change'
  156. },
  157. {
  158. validator: (rule, value, callback) => {
  159. // 调用uView自带的js验证规则,详见:https://www.uviewui.com/js/test.html
  160. return this.$u.test.mobile(value);
  161. },
  162. message: '手机号码不正确',
  163. // 触发器可以同时用blur和change,二者之间用英文逗号隔开
  164. trigger: ['change','blur'],
  165. }],
  166. code: [{
  167. required: true,
  168. message: '请输入验证码',
  169. trigger: 'blur,change'
  170. },
  171. {
  172. min: 6,
  173. max: 6,
  174. message: '验证码为6位数',
  175. trigger: 'change',
  176. },
  177. {
  178. type: 'number',
  179. message: '验证码只能为数字',
  180. trigger: ['change','blur'],
  181. }],
  182. region: [{
  183. required: true,
  184. message: '请选择地区',
  185. trigger: 'change',
  186. }],
  187. addressInfo: [{
  188. required: true,
  189. message: '请选择地区',
  190. trigger: 'change',
  191. }],
  192. },
  193. dataUrl: "",
  194. codeLoading: false,
  195. modelshow: false,
  196. modelcontent: "如果店名和联系人与营业执照不一致,请重新上传清晰度更高的营业执照"
  197. };
  198. },
  199. created() {
  200. uni.$on('licenseData', (data) => {
  201. if(data.company.words!="无"){
  202. this.form.store = data.company.words
  203. }
  204. this.form.company = data.company.words
  205. if(data.company.words!="无"){
  206. this.form.name = data.person.words
  207. }
  208. })
  209. uni.$on('addressData', (data) => {
  210. this.form.latitude = data.latitude
  211. this.form.longitude = data.longitude
  212. this.address=data.address
  213. this.form.region=this.address.province+"-"+this.address.city+"-"+this.address.district
  214. this.form.addressInfo =this.address.addressInfo
  215. })
  216. uni.$on('dataUrl', (data) => {
  217. this.dataUrl = data
  218. })
  219. uni.getSystemInfo({
  220. success: res => {
  221. this.SystemInfo = res
  222. console.log(res)
  223. }
  224. });
  225. if (this.SystemInfo.platform == 'ios') {
  226. this.judgeIosPermission('location')
  227. uni.showModal({
  228. title: "温馨提示",
  229. content: "如果店名和联系人与营业执照不一致,请重新上传清晰度更高的营业执照?",
  230. confirmText: "确认",
  231. showCancel: false
  232. })
  233. } else {
  234. this.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION')
  235. this.modelshow = true
  236. }
  237. },
  238. methods: {
  239. judgeIosPermission(permisionID) {
  240. let result = permision.judgeIosPermission(permisionID)
  241. if (!result) {
  242. this.getLocation()
  243. } else {
  244. this.getLocation()
  245. }
  246. },
  247. async requestAndroidPermission(permisionID) {
  248. let result = await permision.requestAndroidPermission(permisionID)
  249. if (result == 1) {
  250. this.getLocation()
  251. } else if (result == 0) {
  252. this.getLocation()
  253. } else {
  254. this.getLocation()
  255. }
  256. },
  257. getLocation() {
  258. let that = this
  259. uni.getLocation({
  260. type: 'wgs84',
  261. geocode: true,
  262. success: function(res) {
  263. switch (res.address.province) {
  264. case "北京市":
  265. {
  266. that.city = "直辖市"
  267. break;
  268. }
  269. case "天津市":
  270. {
  271. that.city = "直辖市"
  272. break;
  273. }
  274. case "上海市":
  275. {
  276. that.city = "直辖市"
  277. break;
  278. }
  279. case "重庆市":
  280. {
  281. that.city = "直辖市"
  282. break;
  283. }
  284. default:
  285. {
  286. that.city = "不是直辖市"
  287. break;
  288. }
  289. }
  290. if (that.city == "直辖市") {
  291. let RegionData = res.address.province + "," + that.city + "," + res.address.district
  292. that.defaultRegion = RegionData.split(",");
  293. } else {
  294. let RegionData = res.address.province + "," + res.address.city + "," + res.address.district
  295. that.defaultRegion = RegionData.split(",");
  296. }
  297. }
  298. });
  299. },
  300. nextStep() {
  301. this.$refs.uForm.validate(valid => {
  302. if (valid) {
  303. this.$u.route({
  304. url: 'pages/login/register_3',
  305. })
  306. uni.$emit("formData", {
  307. formData: this.form,
  308. dataUrl: this.dataUrl
  309. })
  310. } else {
  311. console.log('验证失败');
  312. }
  313. });
  314. },
  315. codeChange(text) {
  316. this.codeText = text;
  317. },
  318. getCode() {
  319. if (this.form.phone) {
  320. this.codeLoading = true
  321. request({
  322. url: '/sailun/appStoreBasicInfo/sendCode',
  323. method: 'post',
  324. data: {
  325. "phoneNumber": parseInt(this.form.phone),
  326. "opreaType": "0"
  327. },
  328. }).then(res => {
  329. console.log(res)
  330. if (res.data.code == 0) {
  331. if (this.$refs.uCode.canGetCode) {
  332. this.$refs.uCode.start();
  333. } else {
  334. this.$u.toast('倒计时结束后再发送');
  335. }
  336. }
  337. if (res.data.code == 500) {
  338. this.$u.toast(res.data.msg);
  339. }
  340. }).catch(err => {
  341. console.log(err)
  342. }).finally(() => {
  343. this.codeLoading = false
  344. // 通知验证码组件内部开始倒计时
  345. })
  346. } else {
  347. this.$u.toast('请输入手机号');
  348. }
  349. },
  350. regionConfirm(e) {
  351. // this.form.region = e.province.label + '-' + e.city.label + '-' + e.area.label;
  352. // this.form.province = e.province.label;
  353. // this.form.city = e.city.label;
  354. // this.form.district = e.area.label;
  355. },
  356. inMap() {
  357. this.$u.route({
  358. url: 'pages/login/register_map'
  359. })
  360. }
  361. },
  362. onReady() {
  363. this.$refs.uForm.setRules(this.rules);
  364. }
  365. }
  366. </script>
  367. <style lang="scss" scoped>
  368. </style>