bindTel.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <view class="page o-h">
  3. <view class="content bcf">
  4. <!-- logo -->
  5. <view class="ta-c">
  6. <image class="w80 h80 br5 logo" :src="img.logo" />
  7. </view>
  8. <view class="ta-c pb15 f18 fw500 pt5">龍信商城</view>
  9. <!-- 手机号 -->
  10. <view class="pl20 pr20">
  11. <sn-field v-model="data.phone" placeholder="请输入绑定手机号" >
  12. <image :src="img.user"
  13. class="w14 h18 mr15" slot="icon" />
  14. </sn-field>
  15. </view>
  16. <!-- 邀请码 -->
  17. <view class="pl20 pr20" v-if="app.state">
  18. <sn-field v-model="data.invite_code" placeholder="请输入邀请码" >
  19. <image :src="img.invite_code"
  20. class="w14 h18 mr15" slot="icon" />
  21. </sn-field>
  22. </view>
  23. <!-- 验证码 -->
  24. <view class="pl20 pr20">
  25. <sn-field v-model="data.verify_code" placeholder="请输入验证码" >
  26. <image :src="img.code"
  27. class="w14 h18 mr15" slot="icon" />
  28. <sn-get-code slot="button" @submit="getCode"></sn-get-code>
  29. </sn-field>
  30. </view>
  31. <!-- 服务政策,用户协议 -->
  32. <view class="d-f f14 agreement pt15">
  33. <sn-check-box class="mr10" v-model="check" />
  34. <view>查看并同意</view>
  35. <view class="money" @click="goPrivacy">《隐私政策》</view>
  36. <view>及</view>
  37. <view class="money" @click="goAgreement">《服务协议》</view>
  38. </view>
  39. <!-- 注册按钮 -->
  40. <view class="pl30 pr30 ml5 mr5 pt15">
  41. <sn-button round :color="check?'#FC5B62':'#999'"
  42. size="large" @click.native="submit">绑定手机</sn-button>
  43. </view>
  44. <!-- 返回登录 -->
  45. <view class="pl30 pr30 ml5 mr5 pt20 pb30 ta-c f14 c3">
  46. <navigator open-type="navigateBack" hover-class="none">
  47. 返回登录
  48. </navigator>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import SnGetCode from "@/components/getCode.vue"
  55. export default {
  56. onLoad(e){
  57. let _self = this
  58. _self.delta = e.delta*1
  59. _self.data = {invite_code:e.invite_code}
  60. },
  61. data(){
  62. return {
  63. data:{},
  64. img:this.Icon,
  65. phone:"",
  66. delta:1,
  67. check:false,
  68. isSubmit:false,
  69. app:this.$store.state.app
  70. }
  71. },
  72. components:{SnGetCode},
  73. methods: {
  74. //前往隐私政策
  75. goPrivacy(){
  76. // uni.navigateTo({
  77. // url:"/pages/user/privacy"
  78. // })
  79. },
  80. //前往用户协议
  81. goAgreement(){
  82. // uni.navigateTo({
  83. // url:"/pages/user/agreement"
  84. // })
  85. },
  86. getCode(d){
  87. let _self = this
  88. let data = {
  89. phone:_self.data.phone
  90. }
  91. d.sendCode.call(d.t,data)
  92. },
  93. submit(){
  94. let _self = this
  95. if(_self.isSubmit){
  96. return
  97. }
  98. let wxinfo = JSON.parse(uni.getStorageSync("wxinfo"))
  99. let d = _self.data
  100. wxinfo.userInfo.tel = d.phone
  101. wxinfo.userInfo.invite_code = d.invite_code
  102. wxinfo.userInfo.verify_code = d.verify_code
  103. console.log("绑定信息",JSON.stringify(wxinfo))
  104. if(!d.phone){
  105. _self.$api.msg("手机号不能为空")
  106. return
  107. }
  108. if(!d.verify_code){
  109. _self.$api.msg("验证码不能为空")
  110. return
  111. }
  112. _self.isSubmit = true
  113. let data = {wx_info:JSON.stringify(wxinfo)}
  114. _self.request({url:"/Registered/wxLogin",data})
  115. .then(r=>{
  116. console.log(r)
  117. //存储token
  118. if(r.code==200){
  119. uni.setStorageSync("token",r.data)
  120. _self.$store.commit("changeState",{
  121. name:"hasLogin",
  122. value:true
  123. })
  124. _self.showToast({
  125. title:r.msg,
  126. success(){
  127. let tabbar = _self.$store.state.tabbar
  128. tabbar.index = 0
  129. _self.$store.commit("changeState",{
  130. name:"tabbar",
  131. value:tabbar
  132. })
  133. setTimeout(function(){
  134. uni.reLaunch({url:"/pages/home/index"})
  135. },100)
  136. }
  137. })
  138. }
  139. _self.isSubmit = false
  140. })
  141. .catch(()=>{
  142. _self.isSubmit = false
  143. })
  144. }
  145. }
  146. }
  147. </script>
  148. <style scoped lang="scss">
  149. .agreement{
  150. justify-content: center;
  151. }
  152. .page{
  153. height:100vh;
  154. background-image:url("http://lxscimg.liuniu946.com/2019-10-30_5db8eff363eb2.png");
  155. background-size:cover;
  156. background-color:#fff;
  157. }
  158. .content{
  159. margin:200rpx 30rpx 0 30rpx;
  160. border-radius:20rpx;
  161. box-shadow:0 0 20rpx rgba(0,0,0,.1);
  162. }
  163. .logo{
  164. margin-top:-100rpx;
  165. }
  166. .money{
  167. color:$base-color;
  168. }
  169. </style>