register_2.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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: 2,
  138. max: 10,
  139. message: '姓名长度在2到10个字符',
  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.person.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. this.form.province = this.address.province;
  216. this.form.city =this.address.city;
  217. this.form.district =this.address.district;
  218. })
  219. uni.$on('dataUrl', (data) => {
  220. this.dataUrl = data
  221. })
  222. uni.getSystemInfo({
  223. success: res => {
  224. this.SystemInfo = res
  225. console.log(res)
  226. }
  227. });
  228. if (this.SystemInfo.platform == 'ios') {
  229. this.judgeIosPermission('location')
  230. uni.showModal({
  231. title: "温馨提示",
  232. content: "如果店名和联系人与营业执照不一致,请重新上传清晰度更高的营业执照?",
  233. confirmText: "确认",
  234. showCancel: false
  235. })
  236. } else {
  237. this.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION')
  238. this.modelshow = true
  239. }
  240. this.judgeIosPermission()
  241. this.requestAndroidPermission()
  242. },
  243. methods: {
  244. judgeIosPermission(permisionID) {
  245. let result = permision.judgeIosPermission(permisionID)
  246. if (!result) {
  247. uni.getLocation({
  248. type: 'wgs84',
  249. success: res=>{
  250. console.log("获取到定位");
  251. },
  252. fail:err=>{
  253. console.log("没获取到定位")
  254. }
  255. });
  256. } else {
  257. uni.getLocation({
  258. type: 'wgs84',
  259. success: res=>{
  260. console.log("获取到定位");
  261. },
  262. fail:err=>{
  263. console.log("没获取到定位")
  264. }
  265. });
  266. }
  267. },
  268. async requestAndroidPermission(permisionID) {
  269. let result = await permision.requestAndroidPermission(permisionID)
  270. if (result == 1) {
  271. uni.getLocation({
  272. type: 'wgs84',
  273. success: res=>{
  274. console.log("获取到定位");
  275. },
  276. fail:err=>{
  277. console.log("没获取到定位")
  278. }
  279. });
  280. } else if (result == 0) {
  281. uni.getLocation({
  282. type: 'wgs84',
  283. success: res=>{
  284. console.log("获取到定位");
  285. },
  286. fail:err=>{
  287. console.log("没获取到定位")
  288. }
  289. });
  290. } else {
  291. uni.getLocation({
  292. type: 'wgs84',
  293. success: res=>{
  294. console.log("获取到定位");
  295. },
  296. fail:err=>{
  297. console.log("没获取到定位")
  298. }
  299. });
  300. }
  301. },
  302. nextStep() {
  303. this.$refs.uForm.validate(valid => {
  304. if (valid) {
  305. this.$u.route({
  306. url: 'pages/login/register_3',
  307. })
  308. uni.$emit("formData", {
  309. formData: this.form,
  310. dataUrl: this.dataUrl
  311. })
  312. } else {
  313. console.log('验证失败');
  314. }
  315. });
  316. },
  317. codeChange(text) {
  318. this.codeText = text;
  319. },
  320. getCode() {
  321. if (this.form.phone) {
  322. this.codeLoading = true
  323. request({
  324. url: '/sailun/appStoreBasicInfo/sendCode',
  325. method: 'post',
  326. data: {
  327. "phoneNumber": parseInt(this.form.phone),
  328. "opreaType": "0"
  329. },
  330. }).then(res => {
  331. console.log(res)
  332. if (res.data.code == 0) {
  333. if (this.$refs.uCode.canGetCode) {
  334. this.$refs.uCode.start();
  335. } else {
  336. this.$u.toast('倒计时结束后再发送');
  337. }
  338. }
  339. if (res.data.code == 500) {
  340. this.$u.toast(res.data.msg);
  341. }
  342. }).catch(err => {
  343. console.log(err)
  344. }).finally(() => {
  345. this.codeLoading = false
  346. // 通知验证码组件内部开始倒计时
  347. })
  348. } else {
  349. this.$u.toast('请输入手机号');
  350. }
  351. },
  352. regionConfirm(e) {
  353. // this.form.region = e.province.label + '-' + e.city.label + '-' + e.area.label;
  354. // this.form.province = e.province.label;
  355. // this.form.city = e.city.label;
  356. // this.form.district = e.area.label;
  357. },
  358. inMap() {
  359. this.$u.route({
  360. url: 'pages/login/register_map'
  361. })
  362. }
  363. },
  364. onReady() {
  365. this.$refs.uForm.setRules(this.rules);
  366. }
  367. }
  368. </script>
  369. <style lang="scss" scoped>
  370. </style>