invite-proxy.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. <template>
  2. <view v-show="showBox" class="invite-proxy">
  3. <custom-nav noback="noback" transparent="transparent" ref="ltm" title=" " />
  4. <view class="content" v-if="!isOverdue">
  5. <view class="app-item item">
  6. <text>分享人</text>
  7. <text>{{ share_info.user_name }}</text>
  8. </view>
  9. <view class="app-item item">
  10. <text>联系方式</text>
  11. <text>{{ share_info.user_mobile }}</text>
  12. </view>
  13. <view class="form">
  14. <navigator :url="type?'':'../phone-area/phone-area'" class="phone-area">
  15. <text class="text">国家/地区</text>
  16. <text class="area">{{ areaName }}({{ areaCode }})</text>
  17. <text class="icon cuIcon-right"></text>
  18. </navigator>
  19. <view class="item">
  20. <image src="../../static/new_index/phone.png"></image>
  21. <input maxlength="11" type="number" v-model="phone" placeholder="请输入手机号" disabled />
  22. </view>
  23. <!-- <view class="item" v-else>
  24. <image src="../../static/new_index/phone.png"></image>
  25. <input maxlength="11" type="number" v-model="phone" placeholder="请输入手机号" />
  26. <text v-if="phone&&!type" class="cuIcon-roundclosefill" @tap="phone=''"></text>
  27. </view> -->
  28. <view class="item">
  29. <image src="../../static/new_index/sms.png"></image>
  30. <input maxlength="6" type="number" v-model="verifycode" placeholder="请输入6位验证码" />
  31. <text v-if="verifycode" class="cuIcon-roundclosefill" @tap="verifycode=''"></text>
  32. <view class="countdown" @tap="getCode">
  33. <text v-if="countDown">{{ ' ' + countDown }}s</text>
  34. <text v-else>发送验证码</text>
  35. </view>
  36. </view>
  37. <view class="item">
  38. <image src="../../static/new_index/address.png"></image>
  39. <input v-model="address" type="text" @click="choosePicker" placeholder="省/市/区" disabled />
  40. </view>
  41. </view>
  42. <view class="app-item item item-space">
  43. <text>微信昵称</text>
  44. <input v-model="wx_nickname" placeholder="请填写微信昵称" placeholder-class="place" />
  45. </view>
  46. <view class="app-item item">
  47. <text>真实姓名</text>
  48. <input v-model="real_name" maxlength="32" placeholder="请填写真实姓名" placeholder-class="place" />
  49. </view>
  50. <view class="app-item item">
  51. <text>身份证号</text>
  52. <input type="text" @input="inputChange" v-model="id_card_num" maxlength="18" placeholder="请填写身份证号"
  53. placeholder-class="place" />
  54. </view>
  55. <!-- <view class="app-item item">
  56. <text>地址</text>
  57. <input v-model="address" type="text" @click="choosePicker" placeholder="请选择地址" disabled
  58. style="font-size:30rpx;" />
  59. </view> -->
  60. <w-picker ref="Selector" mode="region" themeColor="#F76454" @confirm="onConfirm" />
  61. <button class="big-btn bg" @tap="submit" style="border:none;">立即加入</button>
  62. </view>
  63. <view class="overdue" v-else>
  64. <view class="overdue_con">
  65. <image src="../../static/new_index/top.png" mode="widthFix" style="width: 642rpx;margin-top: 76rpx;">
  66. </image>
  67. <image src="../../static/new_index/safe.png" mode="widthFix" style="width: 310rpx;margin-top: 116rpx;">
  68. </image>
  69. <view class="title flexCC">
  70. <view>该二维码已过期,</view>
  71. <view>请联系客户索取新的二维码进行注册。</view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </template>
  77. <script>
  78. import {
  79. _API_GetVerifyCode,
  80. _API_Reg
  81. } from '@/apis/verify.js'
  82. import {
  83. _API_SubAuthInfo,
  84. getShareInfo
  85. } from '@/apis/user.js'
  86. import WPicker from '@/components/w-picker/w-picker.vue';
  87. import cityPicker from '@/components/citypicker/city-picker.vue';
  88. import areaList from '@/common/util/phone-area.js'
  89. export default {
  90. data() {
  91. return {
  92. showBox: false,
  93. title: '欢迎加入大卫博士',
  94. invite_code: '',
  95. wx_nickname: '',
  96. real_name: '',
  97. id_card_num: '',
  98. areaName: '中国台湾', // 手机号地区名称
  99. areaCode: '+886', // 手机号地区代码
  100. phone: '', // 正常手机号
  101. verifycode: '', // 验证码
  102. countDown: 0, // 倒计时
  103. isREG: true,
  104. src: '',
  105. share_info: {},
  106. address: '', // 地址展示信息
  107. province: '', //省
  108. city: '', //市
  109. area: '', //区
  110. type: '', //邀请类型
  111. time: '', //邀请码到期时间
  112. isOverdue: false, //邀请码是否过期
  113. codeList: areaList, //手机号区域选择
  114. isMatch: /^[a-zA-Z][0-9]{9}$/,
  115. phoneReg: /^[0]{1}[9]{1}\d{8}$/
  116. };
  117. },
  118. computed: {
  119. logged() {
  120. return this.$store.state.app.token
  121. }
  122. },
  123. onLoad({ uuid }) {
  124. uni.$on('CHOOSEPHONECODE', (name, code, reg, phoneReg) => { // 监听 chooseArea 事件更新
  125. this.areaName = name // 修改选择的手机号地区名称
  126. this.areaCode = code // 修改选择的手机号地区代码
  127. this.isMatch = reg //修改选择的手机号地区身份的正则验证
  128. this.phoneReg = phoneReg //手机号正则验证
  129. })
  130. if (!uuid) {
  131. uni.showModal({
  132. content: '客户不存在,请联系分享人',
  133. showCancel: false
  134. })
  135. return false
  136. }
  137. // uni.showModal({
  138. // content: "请确认关注公众号",
  139. // showCancel: false
  140. // })
  141. // this.type = type
  142. this.getShareInfo(uuid)
  143. },
  144. methods: {
  145. // 获取选择到的地址
  146. onConfirm(e) {
  147. this.address = `${e.checkArr[0]}-${e.checkArr[1]}-${e.checkArr[2]}`;
  148. this.province = e.checkArr[0]
  149. this.city = e.checkArr[1]
  150. this.area = e.checkArr[2]
  151. },
  152. /*点击选择地址*/
  153. choosePicker() {
  154. this.$refs.Selector.show();
  155. },
  156. getShareInfo(uuid) {
  157. getShareInfo({ uuid }).then(res => {
  158. if (res.code === 200) {
  159. // 系统维护,禁止注册
  160. if (!res.data.system_status) {
  161. uni.reLaunch({
  162. url: '../safeguard/safeguard'
  163. })
  164. return
  165. }
  166. this.showBox = true
  167. this.share_info = res.data
  168. this.phone = res.data.phone
  169. // 如果是微店铺邀请默认显示手机号和国家区号
  170. // this.phone = this.type ? res.data.customer_mobile : ''
  171. // this.areaCode = this.type ? res.data.area_code : '+86'
  172. if (this.areaCode) {
  173. let index = this.areaCode.indexOf('+')
  174. let code = this.areaCode.substring(index + 1)
  175. this.codeList[0].list.map(i => {
  176. if (i.code === Number(code)) {
  177. this.areaName = i.name
  178. this.isMatch = i.reg
  179. this.phoneReg = i.phoneReg
  180. }
  181. })
  182. }
  183. } else {
  184. uni.showModal({
  185. content: res.msg || '客户不存在,请联系分享人',
  186. showCancel: false
  187. })
  188. }
  189. }).catch(e => {
  190. uni.showModal({
  191. content: JSON.stringify(e)
  192. })
  193. })
  194. },
  195. inputChange() {
  196. this.id_card_num = this.id_card_num.trim()
  197. },
  198. getCode() { // 点击获取手机验证码
  199. if (this.phone.length) { // 手机号是否输入
  200. if (this.countDown) { // 如果正在倒计时
  201. uni.toast('验证码已发送,请稍后重试')
  202. } else {
  203. uni.showLoading({
  204. mask: true
  205. }) // 显示 loading
  206. _API_GetVerifyCode({
  207. mobile: this.phone,
  208. code: this.areaCode,
  209. type: 'invite'
  210. }).then(res => {
  211. if (res.code == 200) {
  212. if (res.data.status == 0) { // 登录 // 0、 1 代表用户是登录 或 注册
  213. this.isREG = false // 隐藏提交
  214. uni.toast('该手机号已注册!请直接登录!') // 提示邀请码发送成功
  215. } else {
  216. this.isREG = true // 显示提交
  217. uni.toast('验证码发送成功') // 提示邀请码发送成功
  218. this.countDown = 120 // 倒计时时长
  219. this.timer = setInterval(() => { // 开始倒计时
  220. this.countDown--
  221. if (this.countDown <= 0) { // 倒计时结束清除倒计时
  222. this.countDown = 0
  223. clearInterval(this.timer)
  224. }
  225. }, 1000)
  226. }
  227. } else if (res.code == 900) {
  228. this.isREG = false // 隐藏提交
  229. uni.toast('该手机号已注册!请直接登录!') // 提示邀请码发送成功
  230. } else { // code 300 表示禁止获取验证码,禁止登录
  231. uni.toast(res.message)
  232. }
  233. })
  234. }
  235. } else {
  236. uni.toast('手机号格式不正确,请重新输入')
  237. }
  238. },
  239. submit() { // 点击登录/注册
  240. if (!this.phone.length) {
  241. uni.toast('手机号格式不正确,请重新输入');
  242. return
  243. }
  244. if (!this.phone.match(this.phoneReg)) {
  245. uni.toast('手机号所属与区号不一致');
  246. return
  247. }
  248. if (!(this.verifycode.length == 6)) {
  249. uni.toast('验证码格式不正确,请重新输入');
  250. return
  251. }
  252. if (!this.wx_nickname.length) {
  253. uni.toast('微信昵称不能为空')
  254. return
  255. }
  256. if (!this.real_name.match(/^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$/)) {
  257. uni.toast('真实姓名不符合要求')
  258. return
  259. }
  260. if (!this.id_card_num.match(this.isMatch)) {
  261. uni.toast('身份号码不合法')
  262. return
  263. }
  264. // if (!this.id_card_num.match(
  265. // /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/)) {
  266. // uni.toast('身份号码不合法')
  267. // return
  268. // }
  269. if (!this.address) {
  270. uni.toast('地址不能为空')
  271. return
  272. }
  273. uni.showLoading({
  274. mask: true
  275. }) // 显示 loading
  276. if (!this.requesting) {
  277. this.requesting = true
  278. setTimeout(() => this.requesting = false, 567)
  279. _API_Reg({
  280. mobile: this.phone,
  281. verify_code: this.verifycode,
  282. recom_code: this.share_info.recom_code,
  283. code: this.areaCode,
  284. wxcode: this.$store.state.userinfo.code,
  285. province: this.province, //省
  286. city: this.city, //市0·
  287. area: this.area, //区
  288. type: '',
  289. }).then(res => {
  290. uni.showLoading({
  291. mask: true
  292. }) // 显示 loading
  293. if (res.code == 200) { // 注册成功
  294. this.$store.commit('app/LOGIN', res.data.token) // 保存 token
  295. _API_SubAuthInfo({ // 提交信息
  296. wechatname: this.wx_nickname,
  297. realname: this.real_name,
  298. cre_num: this.id_card_num,
  299. customer_id: this.type
  300. }).then(res => {
  301. uni.hideLoading()
  302. if (res.code === 200) { // 提交成功
  303. this.$store.commit('userinfo/UPDATA_USERINFO', {
  304. cert_status: 1
  305. })
  306. uni.redirectTo({
  307. url: '../auth-progress/auth-progress'
  308. }) // redirect 到 审核进度页面
  309. } {
  310. uni.showToast({
  311. title: res.message
  312. })
  313. }
  314. })
  315. } else { // 验证码不正确
  316. uni.hideLoading()
  317. uni.showToast({
  318. title: res.message,
  319. icon: 'none'
  320. })
  321. }
  322. })
  323. }
  324. }
  325. }
  326. }
  327. </script>
  328. <style lang="scss" scoped>
  329. .invite-proxy {
  330. @include page();
  331. .content {
  332. #imgWrapper {
  333. flex: 1;
  334. @include flex();
  335. .showCan {
  336. width: 680rpx;
  337. height: 960rpx;
  338. border-radius: 14rpx;
  339. box-shadow: 0px 0px 23px 2px rgba(194, 133, 58, 0.5);
  340. }
  341. }
  342. .app-item {
  343. height: 102rpx;
  344. text {
  345. color: #333;
  346. }
  347. .place {
  348. font-size: 30rpx;
  349. }
  350. }
  351. .sharetext {
  352. font-size: 88rpx;
  353. text-align: center;
  354. margin: 8rpx 0;
  355. box-sizing: border-box;
  356. padding: 0 24rpx;
  357. }
  358. .form {
  359. padding: 30rpx;
  360. margin-top: 10rpx;
  361. box-sizing: border-box;
  362. background-color: #FFFFFF;
  363. .phone-area {
  364. @include flex();
  365. justify-content: space-between;
  366. padding: 10rpx 0;
  367. .text {
  368. font-size: 32rpx;
  369. }
  370. .area {
  371. color: #42b983;
  372. }
  373. }
  374. .item {
  375. @include flex();
  376. height: 110rpx;
  377. padding-top: 20rpx;
  378. box-sizing: border-box;
  379. color: $app-sec-text-color;
  380. border-bottom: 1rpx solid #eee;
  381. .icon,
  382. .cuIcon-roundclosefill {
  383. margin: 0 20rpx;
  384. font-size: 36rpx;
  385. }
  386. image {
  387. width: 48rpx;
  388. height: 48rpx;
  389. }
  390. input {
  391. flex: 1;
  392. height: 84rpx;
  393. margin-left: 15rpx;
  394. }
  395. .countdown {
  396. @include flex();
  397. width: 168rpx;
  398. height: 60rpx;
  399. background: linear-gradient(180deg, #FF232C 0%, #FF571B 100%);
  400. border-radius: 30rpx;
  401. color: #fff;
  402. text {
  403. margin-left: 8rpx;
  404. color: #fff;
  405. }
  406. }
  407. }
  408. }
  409. }
  410. }
  411. .overdue {
  412. width: 100vw;
  413. height: 100vh;
  414. background: #fff;
  415. .overdue_con {
  416. display: flex;
  417. align-items: center;
  418. flex-direction: column;
  419. .title {
  420. color: #333333;
  421. font-size: 32rpx;
  422. margin-top: 136rpx;
  423. view {
  424. margin-bottom: 24rpx;
  425. }
  426. }
  427. }
  428. }
  429. </style>