register_2.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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. this.form.store = data.company.words
  147. this.form.company = data.company.words
  148. this.form.name = data.person.words
  149. })
  150. uni.$on('addressData', (data) => {
  151. this.form.latitude = data.latitude
  152. this.form.longitude = data.longitude
  153. this.form.addressInfo = data.address
  154. })
  155. uni.$on('dataUrl', (data) => {
  156. this.dataUrl = data
  157. })
  158. uni.getSystemInfo({
  159. success:res=>{
  160. this.SystemInfo=res
  161. console.log(res)
  162. }
  163. });
  164. if(this.SystemInfo.platform=='ios'){
  165. this.judgeIosPermission('location')
  166. uni.showModal({
  167. title: "温馨提示",
  168. content: "如果店名和联系人与营业执照不一致,请重新上传清晰度更高的营业执照?",
  169. confirmText: "确认",
  170. showCancel:false
  171. })
  172. }else{
  173. this.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION')
  174. this.modelshow=true
  175. }
  176. },
  177. methods: {
  178. judgeIosPermission(permisionID) {
  179. let result = permision.judgeIosPermission(permisionID)
  180. if(!result){
  181. this.getLocation()
  182. }else{
  183. this.getLocation()
  184. }
  185. },
  186. async requestAndroidPermission(permisionID) {
  187. let result = await permision.requestAndroidPermission(permisionID)
  188. if (result == 1) {
  189. this.getLocation()
  190. } else if (result == 0) {
  191. this.getLocation()
  192. } else {
  193. this.getLocation()
  194. }
  195. },
  196. getLocation(){
  197. let that = this
  198. uni.getLocation({
  199. type: 'wgs84',
  200. geocode: true,
  201. success: function(res) {
  202. switch (res.address.province) {
  203. case "北京市":
  204. {
  205. that.city = "直辖市"
  206. break;
  207. }
  208. case "天津市":
  209. {
  210. that.city = "直辖市"
  211. break;
  212. }
  213. case "上海市":
  214. {
  215. that.city = "直辖市"
  216. break;
  217. }
  218. case "重庆市":
  219. {
  220. that.city = "直辖市"
  221. break;
  222. }
  223. default:
  224. {
  225. that.city = "不是直辖市"
  226. break;
  227. }
  228. }
  229. if (that.city == "直辖市") {
  230. let RegionData = res.address.province + "," + that.city + "," + res.address.district
  231. that.defaultRegion = RegionData.split(",");
  232. } else {
  233. let RegionData = res.address.province + "," + res.address.city + "," + res.address.district
  234. that.defaultRegion = RegionData.split(",");
  235. }
  236. }
  237. });
  238. },
  239. nextStep() {
  240. this.$refs.uForm.validate(valid => {
  241. if (valid) {
  242. this.$u.route({
  243. url: 'pages/login/register_3',
  244. })
  245. uni.$emit("formData", {
  246. formData: this.form,
  247. dataUrl: this.dataUrl
  248. })
  249. } else {
  250. console.log('验证失败');
  251. }
  252. });
  253. },
  254. codeChange(text) {
  255. this.codeText = text;
  256. },
  257. getCode() {
  258. if (this.form.phone) {
  259. this.codeLoading=true
  260. request({
  261. url: '/sailun/appStoreBasicInfo/sendCode',
  262. method: 'post',
  263. data: {
  264. "phoneNumber": parseInt(this.form.phone),
  265. "opreaType":"0"
  266. },
  267. }).then(res => {
  268. console.log(res)
  269. if (res.data.code == 0) {
  270. if (this.$refs.uCode.canGetCode) {
  271. this.$refs.uCode.start();
  272. } else {
  273. this.$u.toast('倒计时结束后再发送');
  274. }
  275. }
  276. if (res.data.code == 500) {
  277. this.$u.toast(res.data.msg);
  278. }
  279. }).catch(err => {
  280. console.log(err)
  281. }).finally(() => {
  282. this.codeLoading=false
  283. // 通知验证码组件内部开始倒计时
  284. })
  285. } else {
  286. this.$u.toast('请输入手机号');
  287. }
  288. },
  289. regionConfirm(e) {
  290. this.form.region = e.province.label + '-' + e.city.label + '-' + e.area.label;
  291. this.form.province = e.province.label;
  292. this.form.city = e.city.label;
  293. this.form.district = e.area.label;
  294. },
  295. inMap() {
  296. this.$u.route({
  297. url: 'pages/login/register_map'
  298. })
  299. }
  300. },
  301. onReady() {
  302. this.$refs.uForm.setRules(this.rules);
  303. }
  304. }
  305. </script>
  306. <style lang="scss" scoped>
  307. </style>