register_2.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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="addressInfo">
  56. <view style="margin-right: 10rpx;">
  57. <u-icon name="map" size="36"></u-icon>
  58. </view>
  59. <u-input placeholder="点击选择详细地址" v-model="form.addressInfo" :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>
  65. <u-verification-code ref="uCode" @change="codeChange"></u-verification-code>
  66. <u-picker mode="region" v-model="pickerShow" @confirm="regionConfirm" :default-region="defaultRegion"></u-picker>
  67. </view>
  68. </u-card>
  69. <view style="margin: 30rpx;">
  70. <u-button @click="nextStep" type="primary">下一步</u-button>
  71. </view>
  72. <u-modal v-model="modelshow" :content="modelcontent" title="温馨提示"></u-modal>
  73. </view>
  74. </template>
  75. <script>
  76. import permision from "@/js_sdk/wa-permission/permission.js"
  77. import {
  78. request
  79. } from '../../common/request/request'
  80. require("promise.prototype.finally").shim()
  81. export default {
  82. data() {
  83. return {
  84. codeText: '',
  85. pickerShow: false,
  86. defaultRegion: [],
  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. company: [{
  108. required: true,
  109. message: '请输入公司名称',
  110. trigger: 'blur,change'
  111. }],
  112. name: [{
  113. required: true,
  114. message: '请输入联系人',
  115. trigger: 'blur,change'
  116. }],
  117. phone: [{
  118. required: true,
  119. message: '请输入联系电话',
  120. trigger: 'blur,change'
  121. }],
  122. code: [{
  123. required: true,
  124. message: '请输入验证码',
  125. trigger: 'blur,change'
  126. }],
  127. region: [{
  128. required: true,
  129. message: '请选择地区',
  130. trigger: 'change',
  131. }],
  132. addressInfo: [{
  133. required: true,
  134. message: '请选择地区',
  135. trigger: 'change',
  136. }],
  137. },
  138. dataUrl: "",
  139. codeLoading:false,
  140. modelshow:false,
  141. modelcontent:"如果店名和联系人与营业执照不一致,请重新上传清晰度更高的营业执照"
  142. };
  143. },
  144. created() {
  145. uni.$on('licenseData', (data) => {
  146. console.log(data)
  147. this.form.store = data.company.words
  148. this.form.company = data.company.words
  149. this.form.name = data.person.words
  150. })
  151. uni.$on('addressData', (data) => {
  152. this.form.latitude = data.latitude
  153. this.form.longitude = data.longitude
  154. this.form.addressInfo = data.address
  155. })
  156. uni.$on('dataUrl', (data) => {
  157. this.dataUrl = data
  158. })
  159. uni.getSystemInfo({
  160. success:res=>{
  161. this.SystemInfo=res
  162. console.log(res)
  163. }
  164. });
  165. if(this.SystemInfo.platform=='ios'){
  166. this.judgeIosPermission('location')
  167. uni.showModal({
  168. title: "温馨提示",
  169. content: "如果店名和联系人与营业执照不一致,请重新上传清晰度更高的营业执照?",
  170. confirmText: "确认",
  171. showCancel:false
  172. })
  173. }else{
  174. this.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION')
  175. this.modelshow=true
  176. }
  177. },
  178. methods: {
  179. judgeIosPermission(permisionID) {
  180. let result = permision.judgeIosPermission(permisionID)
  181. if(!result){
  182. this.getLocation()
  183. }else{
  184. this.getLocation()
  185. }
  186. },
  187. async requestAndroidPermission(permisionID) {
  188. let result = await permision.requestAndroidPermission(permisionID)
  189. if (result == 1) {
  190. this.getLocation()
  191. } else if (result == 0) {
  192. this.getLocation()
  193. } else {
  194. this.getLocation()
  195. }
  196. },
  197. getLocation(){
  198. let that = this
  199. uni.getLocation({
  200. type: 'wgs84',
  201. geocode: true,
  202. success: function(res) {
  203. switch (res.address.province) {
  204. case "北京市":
  205. {
  206. that.city = "直辖市"
  207. break;
  208. }
  209. case "天津市":
  210. {
  211. that.city = "直辖市"
  212. break;
  213. }
  214. case "上海市":
  215. {
  216. that.city = "直辖市"
  217. break;
  218. }
  219. case "重庆市":
  220. {
  221. that.city = "直辖市"
  222. break;
  223. }
  224. default:
  225. {
  226. that.city = "不是直辖市"
  227. break;
  228. }
  229. }
  230. if (that.city == "直辖市") {
  231. let RegionData = res.address.province + "," + that.city + "," + res.address.district
  232. that.defaultRegion = RegionData.split(",");
  233. } else {
  234. let RegionData = res.address.province + "," + res.address.city + "," + res.address.district
  235. that.defaultRegion = RegionData.split(",");
  236. }
  237. }
  238. });
  239. },
  240. nextStep() {
  241. this.$refs.uForm.validate(valid => {
  242. if (valid) {
  243. this.$u.route({
  244. url: 'pages/login/register_3',
  245. })
  246. uni.$emit("formData", {
  247. formData: this.form,
  248. dataUrl: this.dataUrl
  249. })
  250. } else {
  251. console.log('验证失败');
  252. }
  253. });
  254. },
  255. codeChange(text) {
  256. this.codeText = text;
  257. },
  258. getCode() {
  259. if (this.form.phone) {
  260. this.codeLoading=true
  261. request({
  262. url: '/sailun/appStoreBasicInfo/sendCode',
  263. method: 'post',
  264. data: {
  265. "phoneNumber": parseInt(this.form.phone),
  266. "opreaType":"0"
  267. },
  268. }).then(res => {
  269. console.log(res)
  270. if (res.data.code == 0) {
  271. if (this.$refs.uCode.canGetCode) {
  272. this.$refs.uCode.start();
  273. } else {
  274. this.$u.toast('倒计时结束后再发送');
  275. }
  276. }
  277. if (res.data.code == 500) {
  278. this.$u.toast(res.data.msg);
  279. }
  280. }).catch(err => {
  281. console.log(err)
  282. }).finally(() => {
  283. this.codeLoading=false
  284. // 通知验证码组件内部开始倒计时
  285. })
  286. } else {
  287. this.$u.toast('请输入手机号');
  288. }
  289. },
  290. regionConfirm(e) {
  291. this.form.region = e.province.label + '-' + e.city.label + '-' + e.area.label;
  292. this.form.province = e.province.label;
  293. this.form.city = e.city.label;
  294. this.form.district = e.area.label;
  295. },
  296. inMap() {
  297. this.$u.route({
  298. url: 'pages/login/register_map'
  299. })
  300. }
  301. },
  302. onReady() {
  303. this.$refs.uForm.setRules(this.rules);
  304. }
  305. }
  306. </script>
  307. <style lang="scss" scoped>
  308. </style>