微信

bindMobile.vue 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <div class="mainPage">
  3. <div class="mask">
  4. <img :src="logo" class="logo" alt="">
  5. <div class="box">
  6. <div class="title">绑定</div>
  7. <div class="mobile">
  8. <i class="iconfont icon-dianhua"></i>
  9. <input type="number" maxlength="11" placeholder="手机号" v-model="postData.phone">
  10. </div>
  11. <div class="recommend">
  12. <span>推荐人</span>
  13. <div @click="selectCase">
  14. <span>{{caseName}}</span>
  15. <i class="iconfont icon-triangle-bottom"></i>
  16. </div>
  17. <div @click="selectSales">
  18. <span>{{salesName}}</span>
  19. <i class="iconfont icon-triangle-bottom"></i>
  20. </div>
  21. </div>
  22. <div class="sms">
  23. <i class="iconfont icon-mima"></i>
  24. <input type="number" maxlength="6" placeholder="验证码" v-model="postData.captcha">
  25. <div class="sand" v-if="seconds === 61" @click="sandMsg">发送验证码</div>
  26. <div class="sand" v-else>{{seconds}}后可重发</div>
  27. </div>
  28. <div class="submit" @click="submit">
  29. <div>提交</div>
  30. </div>
  31. </div>
  32. <transition name="slide">
  33. <div class="select" v-if="showCase">
  34. <van-picker
  35. show-toolbar
  36. title="请选择"
  37. value-key='CaseName'
  38. :columns="columns"
  39. @cancel="onCancelC"
  40. @confirm="onConfirmC"
  41. />
  42. </div>
  43. </transition>
  44. <transition name="slide">
  45. <div class="select" v-if="showSales">
  46. <van-picker
  47. show-toolbar
  48. title="请选择"
  49. value-key='UserName'
  50. :columns="columnsS"
  51. @cancel="onCancelS"
  52. @confirm="onConfirmS"
  53. />
  54. </div>
  55. </transition>
  56. </div>
  57. </div>
  58. </template>
  59. <script>
  60. import logo from '../../../common/icon/logo.png'
  61. import { mapState, createNamespacedHelpers } from 'vuex'
  62. const { mapActions: actions } = createNamespacedHelpers('userCenter')
  63. export default {
  64. data () {
  65. return {
  66. logo,
  67. showCase: false,
  68. showSales: false,
  69. columns: [],
  70. columnsS: [],
  71. caseName: '选择案场',
  72. salesName: '选择销售',
  73. seconds: 61,
  74. postData: {
  75. phone: '',
  76. case: '',
  77. sales: '',
  78. captcha: ''
  79. }
  80. }
  81. },
  82. computed: {
  83. ...mapState({
  84. caseInfo: x => x.userCenter.caseInfo
  85. })
  86. },
  87. created () {
  88. this.getCaseInfo(1).then(() => {
  89. this.columns = this.caseInfo.cases
  90. })
  91. },
  92. methods: {
  93. ...actions(['getCaseInfo']),
  94. ...actions(['getCaptcha']),
  95. ...actions(['submitData']),
  96. onConfirmC (value, index) {
  97. this.caseName = value.CaseName
  98. this.postData.case = value.CaseId
  99. this.columnsS = []
  100. this.salesName = '选择销售'
  101. if (this.caseInfo.sales) {
  102. for (let i = 0; i < this.caseInfo.sales.length; i++) {
  103. if (this.caseInfo.sales[i].CaseId === this.postData.case) {
  104. this.columnsS.push(this.caseInfo.sales[i])
  105. }
  106. }
  107. }
  108. this.showCase = false
  109. },
  110. onCancelC () {
  111. this.showCase = false
  112. },
  113. onConfirmS (value, index) {
  114. this.salesName = value.UserName
  115. this.postData.sales = value.UserId
  116. this.showSales = false
  117. },
  118. onCancelS () {
  119. this.showSales = false
  120. },
  121. selectCase () {
  122. this.showCase = true
  123. },
  124. selectSales () {
  125. if (!this.postData.case) {
  126. this.$toast('请先选择案场')
  127. return
  128. } else if (this.columnsS.length <= 0) {
  129. this.$toast('此案场无销售')
  130. return
  131. }
  132. this.showSales = true
  133. },
  134. sandMsg () {
  135. if (!this.postData.phone) {
  136. this.$toast('请先填写手机号')
  137. return
  138. }
  139. this.getCaptcha(this.postData.phone)
  140. this.seconds = 60
  141. this.runTime()
  142. },
  143. runTime () {
  144. setTimeout(() => {
  145. this.seconds--
  146. if (this.seconds < 60 && this.seconds >= 1) {
  147. this.runTime()
  148. } else if (this.seconds < 1) {
  149. this.seconds = 61
  150. }
  151. }, 1000)
  152. },
  153. submit () {
  154. if (!this.postData.captcha) {
  155. this.$toast('请先获取验证码')
  156. return
  157. }
  158. if (!this.postData.case) {
  159. this.$toast('请选择案场')
  160. return
  161. }
  162. if (!this.postData.sales) {
  163. this.$toast('请选择销售')
  164. return
  165. }
  166. this.submitData(this.postData).then((res) => {
  167. this.$toast(res)
  168. if (this.$route.query.isLottery) {
  169. setTimeout(() => {
  170. const from = this.$route.query.luckshare ? `#/from/${this.$route.query.luckshare}` : ''
  171. window.location.href = `${window.location.origin}/game/luckdraw/${from}`
  172. }, 2000)
  173. } else {
  174. setTimeout(() => {
  175. // this.$router.push({name: 'userCenter'})
  176. window.history.go(-1)
  177. }, 300)
  178. }
  179. })
  180. }
  181. }
  182. }
  183. </script>
  184. <style lang="scss" scoped>
  185. @import 'page.scss';
  186. </style>