wechat.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <view class="container">
  3. <TopBar></TopBar>
  4. <view class="line-bar flex-between">
  5. <view class="span active"></view>
  6. <view class="span active"></view>
  7. <view class="span active"></view>
  8. <view class="span active"></view>
  9. <view class="span active"></view>
  10. </view>
  11. <view class="title font44 fw600">
  12. 设置你的微信号
  13. </view>
  14. <view class="tip font28 fw400">
  15. 如果你不在线,他可以添加你的微信
  16. </view>
  17. <view class="label-box flex-between">
  18. <view class="left font28 fw400">
  19. 微信号
  20. </view>
  21. </view>
  22. <view class="input-box flex-between">
  23. <input type="text" maxlength="10" placeholder="请填写真实正确的微信号" placeholder-style="color:#494667;font-size:28rpx;" class="input fw500 font32" :value="wechat" @input="wechatInput">
  24. </view>
  25. <view class="select-title font28 fw400">
  26. 设置查看权限
  27. </view>
  28. <picker mode="selector" :range="auths" range-key="value" @change="authsChange">
  29. <view class="select flex-between">
  30. <view class="select-val font28 fw400" :style="{'color':`${height===''?'':'#ffffff'}`}">
  31. {{auth}}
  32. </view>
  33. <image :src="`${assetsUrl}info-figure-select.png`" mode="aspectFill" class="select-icon"></image>
  34. </view>
  35. </picker>
  36. <cover-view class="btn font32 fw600" @click="sure">
  37. 下一步
  38. </cover-view>
  39. </view>
  40. </template>
  41. <script>
  42. import TopBar from '@/components/TopBar/TopBar.vue';
  43. import ImageCropper from "@/components/invinbg-image-cropper/invinbg-image-cropper.vue";
  44. export default {
  45. components:{TopBar,ImageCropper},
  46. data() {
  47. return {
  48. assetsUrl:this.$util.assetsUrl,
  49. auths:[],
  50. auth:'',
  51. wechat:'',
  52. saveOption:{
  53. completeUser: {},
  54. weiXinStatusEnum: 'WxM2F5'
  55. }
  56. };
  57. },
  58. mounted() {
  59. let user=JSON.parse(uni.getStorageSync('user'));
  60. if(user.sex==='Famale'){
  61. this.auths=[
  62. {key:'WxM2F5',value:'对VIP公开或使用颜豆、权益卡查看'},
  63. {key:'WaitAuth',value:'经过我授权才能查看微信'},
  64. ]
  65. this.auth='对VIP公开或使用颜豆、权益卡查看';
  66. }
  67. else if(user.sex==='Male'){
  68. this.auths=[
  69. {key:'WxF2M7',value:'对完成真人认证的女士公开'},
  70. {key:'WaitAuth',value:'经过我授权才能查看微信'},
  71. ]
  72. this.auth='对完成真人认证的女士公开';
  73. }
  74. },
  75. methods:{
  76. sure(){
  77. let user=JSON.parse(uni.getStorageSync('user'));
  78. if(this.$util.checkChinese(this.wechat)){uni.showToast({title:'微信号格式有误,请重新输入',icon:'none'});return;}
  79. if(this.wechat===''&&user.sex==='Famale'){uni.showToast({title:'请填写微信号',icon:'none'});return;}
  80. user.wxId=this.wechat;
  81. this.saveOption.completeUser=user;
  82. uni.showLoading({
  83. title:'保存中',
  84. mask:true
  85. })
  86. this.$api.login.saveWechat(this.saveOption).then(res=>{
  87. uni.hideLoading();
  88. if(res.data.succ){
  89. uni.setStorageSync('regStep','Index');
  90. uni.setStorageSync('user',JSON.stringify(user));
  91. uni.showToast({
  92. icon:'success',
  93. title:'保存成功'
  94. });
  95. this.$api.public.wxConfig({status:this.saveOption.weiXinStatusEnum}).then(res=>{})
  96. this.getMineDetail();
  97. uni.switchTab({
  98. url:'/pages/friends/friends'
  99. })
  100. }
  101. })
  102. },
  103. wechatInput(e){
  104. let value=(e.detail.value||'').trim();
  105. if(value){
  106. const reg = /[\u4e00-\u9fa5]/ig;
  107. if ((reg.test(value))) {
  108. value = value.replace(reg, '');
  109. return;
  110. }
  111. }
  112. this.wechat=e.detail.value;
  113. },
  114. authsChange(e){
  115. this.auth=this.auths[e.detail.value].value;
  116. this.saveOption.weiXinStatusEnum=this.auths[e.detail.value].key;
  117. },
  118. confirm(e) {
  119. this.tempFilePath = ''
  120. this.cropFilePath = e.detail.tempFilePath;
  121. this.btnText="下一步";
  122. this.$refs.popup.close();
  123. },
  124. getMineDetail(){
  125. let user=JSON.parse(uni.getStorageSync('user'));
  126. this.$api.public.mineDetail({
  127. getAlbum:true,
  128. completeUser:user
  129. }).then(res=>{
  130. this.$store.commit('setUserInfo',res.data);
  131. uni.setStorageSync('userInfo',JSON.stringify(res.data));//正式环境删除
  132. })
  133. },
  134. }
  135. }
  136. </script>
  137. <style lang="scss" scoped>
  138. .container{
  139. width: 100vw;
  140. min-height: 100vh;
  141. background-color: $bgcolor1;
  142. .line-bar{
  143. margin: 0 60rpx;
  144. margin-top: 30rpx;
  145. .span{
  146. width: 120rpx;
  147. height: 8rpx;
  148. border-radius: 4rpx 0rpx 0rpx 4rpx;
  149. background-color: $bgcolor4;
  150. }
  151. .active{
  152. background-color: $primary;
  153. }
  154. }
  155. .title{
  156. color: $fontcolor5;
  157. padding-left: 60rpx;
  158. margin-top: 108rpx;
  159. }
  160. .tip{
  161. color: $fontcolor3;
  162. padding-left: 60rpx;
  163. margin-top: 8rpx;
  164. }
  165. .label-box{
  166. margin: 0 60rpx;
  167. margin-top: 56rpx;
  168. .left{
  169. color: $fontcolor3;
  170. }
  171. }
  172. .input-box{
  173. margin: 0rpx 60rpx;
  174. margin-top: 16rpx;
  175. background-color: $bgcolor3;
  176. border-radius: 16rpx;
  177. height: 112rpx;
  178. padding: 0rpx 32rpx;
  179. .input{
  180. color: $fontcolor5;
  181. }
  182. }
  183. .select-title{
  184. color: $fontcolor3;
  185. margin: 0 60rpx;
  186. margin-top: 56rpx;
  187. }
  188. .select{
  189. background-color: $bgcolor3;
  190. margin: 0 60rpx;
  191. margin-top: 16rpx;
  192. height: 112rpx;
  193. border-radius: 16px;
  194. padding: 0 36rpx;
  195. .select-val{
  196. color: $fontcolor1;
  197. }
  198. .select-icon{
  199. width: 24rpx;
  200. height: 24rpx;
  201. }
  202. }
  203. .btn{
  204. position: fixed;
  205. z-index: 999;
  206. left: 0;
  207. right: 0;
  208. bottom: 44rpx;
  209. margin: auto;
  210. width: 630rpx;
  211. height: 104rpx;
  212. border-radius: 52rpx;
  213. background-color: $primary;
  214. color: $fontcolor5;
  215. text-align: center;
  216. line-height: 104rpx;
  217. }
  218. }
  219. .input-num{
  220. color: $fontcolor2;
  221. }
  222. </style>