index.vue 6.6 KB

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