时空网前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

158 lines
4.3 KiB

5 years ago
5 years ago
  1. <template>
  2. <view>
  3. <view class="lf-row-center lf-flex-column box">
  4. <image class="img"></image>
  5. <view class="lf-m-t-10 lf-font-32" v-if="type == 'phone'">游客jdsfbuskdnko</view>
  6. <block v-if="type == 'userinfo'">
  7. <button class="btn" @click="getUserProfile">
  8. <u-icon name="weixin-fill" color="#ffffff" size="60" class="lf-text-vertical"></u-icon>
  9. <text class="lf-m-l-20">绑定微信</text>
  10. </button>
  11. <view class="lf-m-t-40 lf-font-28" @click="$toBack()">暂不绑定继续操作</view>
  12. </block>
  13. <block v-else-if="type == 'phone'">
  14. <button class="btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
  15. <u-icon name="weixin-fill" color="#ffffff" size="60" class="lf-text-vertical"></u-icon>
  16. <text class="lf-m-l-20">微信快捷登录</text>
  17. </button>
  18. <!-- <view class="lf-m-t-40 lf-font-28" @click="$url('/pages/login/accountLogin')">使用手机号登录</view> -->
  19. <view class="mask" v-if="!checked" @click="$msg('您未同意协议条款')"></view>
  20. </block>
  21. </view>
  22. <!-- 服务条款 -->
  23. <view class="fixed-bottom" v-if="type == 'phone'">
  24. <checkbox-group @change="checkboxChange" style="display: inline-block;">
  25. <checkbox class="lf-text-vertical" :checked="checked"></checkbox>
  26. </checkbox-group>
  27. <text class="lf-m-l-10 lf-font-24 lf-color-gray">
  28. <text>请认真阅读并同意</text>
  29. <text class="highlight" @click="enterAgree">时空网协议</text>
  30. <text>在小程序下单购买即表示您已默认同意</text>
  31. <text class="highlight" @click="enterAgree">时空网协议</text>
  32. <text>的所有条款</text>
  33. </text>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. data(){
  40. return {
  41. checked: false, // 是否勾选协议
  42. isLogin: false, // 是否已登录
  43. userInfo: {},
  44. type: 'userinfo', // 页面授权类型 phone获取手机号 | userinfo获取用户信息
  45. }
  46. },
  47. onLoad(options){
  48. this.type = options.type || this.type;
  49. getApp().globalData.wxlogin(); // 重新登录
  50. },
  51. methods: {
  52. // 进入查看协议
  53. enterAgree(){
  54. console.log("查看协议");
  55. this.$url('/pages/agreement/agreement');
  56. },
  57. // 勾选协议发生变化
  58. checkboxChange(event){
  59. this.checked = event.detail.value.length > 0;
  60. },
  61. // 微信快捷登录获取手机号
  62. getPhoneNumber(event){
  63. console.log(event);
  64. if(event.detail.errMsg == 'getPhoneNumber:ok'){
  65. let encryptedData = event.detail.encryptedData;
  66. let iv = event.detail.iv;
  67. let userInfo = uni.getStorageSync('userinfo') || {};
  68. this.$http(this.API.API_WECHAT_SETPHONE, {
  69. encryptedData,
  70. iv,
  71. token: userInfo.token
  72. }).then(res => {
  73. console.log("更新手机号", res);
  74. this.$msg('更新成功', {icon: 'success'});
  75. uni.setStorageSync('userinfo', res.data);
  76. this.$toBack();
  77. })
  78. }
  79. },
  80. // 获取用户信息
  81. getUserProfile(){
  82. uni.getUserProfile({
  83. desc: '您的信息将用于时空网显示',
  84. lang: 'zh_CN',
  85. complete: result => {
  86. console.log(result)
  87. if(result.errMsg == 'getUserProfile:ok'){
  88. let encryptedData = result.encryptedData;
  89. let iv = result.iv;
  90. let signature = result.signature;
  91. let userInfo = uni.getStorageSync('userinfo') || {};
  92. this.$http(this.API.API_WECHAT_SETPROFILE, {
  93. encryptedData,
  94. iv,
  95. token: userInfo.token
  96. }).then(res => {
  97. console.log("更新用户信息", res);
  98. this.$msg('更新成功', {icon: 'success'});
  99. uni.setStorageSync('userinfo', res.data);
  100. this.$toBack();
  101. })
  102. }
  103. }
  104. });
  105. }
  106. }
  107. }
  108. </script>
  109. <style>
  110. page{
  111. overflow: hidden;
  112. }
  113. </style>
  114. <style lang="scss" scoped="scoped">
  115. .box{
  116. padding: 60rpx 32rpx;
  117. width: 750rpx;
  118. height: auto;
  119. box-sizing: border-box;
  120. position: relative;
  121. .img{
  122. width: 180rpx;
  123. height: 180rpx;
  124. border-radius: 50%;
  125. background-color: #EEEEEE;
  126. }
  127. .btn{
  128. background-color: #09BB07;
  129. color: #FFFFFF;
  130. width: 100%;
  131. height: 88rpx;
  132. border-radius: 42rpx;
  133. font-size: 32rpx;
  134. line-height: 88rpx;
  135. margin-top: 80rpx;
  136. }
  137. }
  138. .fixed-bottom{
  139. position: fixed;
  140. bottom: 60rpx;
  141. left: 0;
  142. padding: 0 32rpx;
  143. .highlight{
  144. color: #1e90ff;
  145. }
  146. }
  147. .mask{
  148. position: absolute;
  149. bottom: 46rpx;
  150. left: 0;
  151. width: 100%;
  152. height: 190rpx;
  153. }
  154. </style>