index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <view>
  3. <view class="ceng"></view>
  4. <view class="update-pop" :style="'bottom:'+updateBottom">
  5. <view class="update-close1" @click="closeUpdate">
  6. <image src="../../static/pages/images/close1.png"></image>
  7. </view>
  8. <block v-if="updateInfo">
  9. <!-- <image :src="picUrlss+'update_info.png'" class="update-img"></image> -->
  10. <view class="project ddflex">
  11. <!-- <image :src="config.CONFIG_PROJECT_LOGO" mode="aspectFill"></image> -->
  12. <!-- {{config.CONFIG_PROJECT_TITLE}}<text>申请</text> -->
  13. <view class="fflex">
  14. <view>建议完善头像与昵称</view>
  15. <text>便于更好地为您提供服务</text>
  16. </view>
  17. </view>
  18. <!-- <view class="huoqu-text">获取你的昵称、头像</view> -->
  19. <!-- <view class="update-tip">完善头像/昵称信息</view> -->
  20. <view class="update-form">
  21. <button open-type="chooseAvatar" hover-class="none" class="update-avatar ddflex fflex" @chooseavatar="uploadAvatar">
  22. <image :src="avatar?avatar:picUrlss+'update_userimg.png'" class="update-avatars" style="border-radius: 50%;"></image>
  23. <!-- <image :src="picUrlss + 'upload_avatar.png'" class="update-avatars" v-else></image> -->
  24. <view class="update-pic ddflex">
  25. <image :src="picUrlss + 'upload_white.png'"></image>
  26. </view>
  27. </button>
  28. <input type="nickname" v-model="nickName" placeholder="获取微信昵称" placeholder-class="update-placeholder" class="update-ipt fflex" @blur="getNickname" />
  29. </view>
  30. <view class="ment ddflex">
  31. <image :src="'../../static/pages/images/'+(isAgree?'gou_h.png':'gou.png')" @click="agree()"></image>
  32. <view class="ddflex">我已阅读并同意<navigator url="/mine/page/page?title=用户协议&isXieyi=true" hover-class="none" class="xieyi">用户协议</navigator>,<navigator url="/mine/page/page?title=隐私声明&isYinsi=true" hover-class="none" class="xieyi">隐私声明</navigator></view>
  33. </view>
  34. <view class="update-btn" @click="updateInfos">保存并继续使用</view>
  35. <!-- <view class="update-btns ddflex">
  36. <view class="update-btn-jj" @click="closeUpdate()">拒绝</view>
  37. <view class="update-btn-yx" @click="updateInfos()">允许</view>
  38. </view> -->
  39. </block>
  40. <view class="bind-mobile" v-if="updateMobile && !updateInfo">
  41. <image :src="config.CONFIG_PROJECT_LOGO" mode="aspectFill" class="pro-logo" v-if="config.CONFIG_PROJECT_LOGO"></image>
  42. <!-- <image :src="picUrlss + 'blue/update_phone.png'" class="update-img"></image> -->
  43. <view class="update-tip">{{config.CONFIG_PROJECT_TITLE}}<view>更多服务,请{{isBind ? '绑定手机号':'授权登录'}}</view></view>
  44. <view class="ment ddflex">
  45. <image :src="'../../static/pages/images/'+(isAgree?'gou_h.png':'gou.png')" @click="agree()"></image>
  46. <view class="ddflex">我已阅读并同意<navigator url="/mine/page/page?title=用户协议&isXieyi=true" hover-class="none" class="xieyi">用户协议</navigator>,<navigator url="/mine/page/page?title=隐私声明&isYinsi=true" hover-class="none" class="xieyi">隐私声明</navigator></view>
  47. </view>
  48. <button class="update-btn ddflex" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" style="margin-top: 80rpx !important;" v-if="isAgree"><image :src="picUrlss+'bind_m.png'"></image>{{isBind ? '绑定手机号':'一键登录'}}</button>
  49. <view class="update-btn ddflex" style="margin-top: 80rpx !important;" @click="checkAgree" v-else><image :src="picUrlss+'bind_m.png'"></image>{{isBind ? '绑定手机号':'一键登录'}}</view>
  50. <view class="zanbu" @click="closeUpdate">暂不{{isBind ? '绑定':'登录'}}</view>
  51. </view>
  52. <!-- <image :src="picUrlss + 'update_close.png'" class="update-close" @click="closeUpdate"></image> -->
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. const app = getApp();
  58. const req = require('../../utils/request.js');
  59. export default {
  60. data() {
  61. return {
  62. picUrlss: req.public.picUrls,
  63. config: '',
  64. avatar: '',
  65. nickName: '',
  66. isAgree: false,
  67. updateBottom: '-100%'
  68. };
  69. },
  70. components: {},
  71. props: {
  72. updateInfo: {
  73. type: Boolean,
  74. default: false
  75. },
  76. updateMobile: {
  77. type: Boolean,
  78. default: false
  79. },
  80. isUpdate: {
  81. type: Boolean,
  82. default: false
  83. }
  84. },
  85. watch: {},
  86. mounted() {
  87. // console.log('ready');
  88. // console.log('isUpdateInfo==',this.updateInfo)
  89. // console.log('isUpdateMobile==',this.updateMobile)
  90. this.config = JSON.parse(req.getStorage('configRes'));
  91. this.updateBottom = 0
  92. // this.avatar = req.getStorage('userInfo').avatar;
  93. // this.nickName = req.getStorage('userInfo').nickName;
  94. },
  95. methods: {
  96. uploadAvatar(e) {
  97. uni.showLoading({
  98. title: '头像上传中'
  99. });
  100. req.uploadFile('/api/upload', e.detail.avatarUrl, res => {
  101. this.avatar = res.src;
  102. this.confirm(false,false);
  103. uni.hideLoading();
  104. });
  105. },
  106. getNickname: function(e) {
  107. this.nickName = e.detail.value;
  108. if(e.detail.value) this.confirm(false,false);
  109. },
  110. agree(){
  111. this.isAgree = !this.isAgree;
  112. },
  113. updateInfos() {
  114. let that = this;
  115. if(!this.isAgree) return req.msg('请先同意用户协议');
  116. if (!this.avatar) return req.msg('请点击获取你的微信头像');
  117. if (!this.nickName) return req.msg('请输入昵称');
  118. // this.confirm(true,true);
  119. that.closeUpdate(1);
  120. },
  121. confirm(isShow,isClose) {
  122. let that = this;
  123. let d = {};
  124. if(that.avatar) d.avatar = that.avatar;
  125. if(that.nickName) d.nickName = that.nickName;
  126. req.postRequest('/api/user/save',d,res => {
  127. let userInfo = req.getStorage('userInfo');
  128. if(that.avatar) userInfo.avatar = that.avatar;
  129. if(that.nickName) userInfo.nickName = that.nickName;
  130. req.setStorage('userInfo', userInfo);
  131. if(isClose){
  132. this.closeUpdate(2);
  133. }
  134. req.removeStorage('isShowUpdateInfo')
  135. },isShow);
  136. },
  137. checkAgree(){
  138. if(!this.isAgree) return req.msg('请先同意用户协议');
  139. },
  140. getPhoneNumber(e) {
  141. let that = this;
  142. let sessionKey = '';
  143. app.globalData.getCheckSessoin(json => {
  144. sessionKey = json.session_key;
  145. let _params = {
  146. sessionKey: sessionKey,
  147. iv: e.detail.iv,
  148. encryptedData: e.detail.encryptedData
  149. };
  150. if (req.getStorage('pidCode')) {
  151. _params.parentId = req.getStorage('pidCode');
  152. }
  153. if (e.detail.errMsg == 'getPhoneNumber:ok') {
  154. req.postRequest('/api/weixin/mobile', _params, json => {
  155. if (json.mobile) {
  156. var userInfo = req.getStorage('userInfo');
  157. userInfo.mobile = json.mobile;
  158. req.setStorage('userInfo', userInfo);
  159. that.closeUpdate();
  160. req.removeStorage('isShowUpdateMobile')
  161. }
  162. });
  163. } else {
  164. }
  165. });
  166. },
  167. closeUpdate(type) {
  168. this.updateBottom = '-100%'
  169. this.$emit('closeUpdate');
  170. if(this.isUpdate) this.$emit('updateMobileInfo',type)
  171. }
  172. }
  173. };
  174. </script>
  175. <style>
  176. @import './index.css';
  177. </style>