index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <app-layout class="app-my">
  3. <view class="container">
  4. <view class="customer">
  5. <view class="bg"></view>
  6. <view class="info dir-top-wrap cross-center main-center">
  7. <view class="head-img" @click="handleGetInfo">
  8. <u-image
  9. width="140"
  10. height="140"
  11. :src="userData.head_img"
  12. shape="circle"></u-image>
  13. </view>
  14. <view class="nickname">
  15. <template v-if="userData.nickname !== '微信用户'">{{userData.nickname}}</template>
  16. <template v-else>
  17. <u-button @click="handleGetInfo"
  18. type="success"
  19. size="mini"
  20. :custom-style="{backgroundColor: '#097268'}">获取头像/昵称</u-button>
  21. </template>
  22. </view>
  23. <view class="mobile">
  24. <!--#ifdef MP-WEIXIN-->
  25. <u-button size="mini"
  26. v-if="!userData.phone_num"
  27. :custom-style="{backgroundColor: '#097268'}"
  28. type="success" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">获取手机号</u-button>
  29. <text v-else>{{userData.phone_num}}</text>
  30. <!--#endif-->
  31. </view>
  32. </view>
  33. </view>
  34. <u-cell-group :border="false" class="tab-list">
  35. <u-cell-item title="桥架会员" :border-bottom="false" bg-color="#f9f9f9" @click="handleJumpBuy" v-if="!setting.review_mode">
  36. <view slot="icon" class="icon bridge"></view>
  37. </u-cell-item>
  38. <u-cell-item title="会员购买记录" :border-bottom="false" bg-color="#f9f9f9" v-if="!setting.review_mode" @click="$jump({url:'/pages/my/member-record',type:'to'})">
  39. <view slot="icon" class="icon member"></view>
  40. </u-cell-item>
  41. <u-cell-item title="分销中心" v-if="setting.open_share" :border-bottom="false" bg-color="#f9f9f9" @click="$jump({url:'/pages/share/index',type:'to'})">
  42. <view slot="icon" class="icon share"></view>
  43. </u-cell-item>
  44. <u-cell-item title="微信号" :border-bottom="false" bg-color="#f9f9f9" @click="handleCopy">
  45. {{setting.service_wechat}}
  46. <view slot="icon" class="icon wechat"></view>
  47. </u-cell-item>
  48. <u-cell-item title="在线客服" :border-bottom="false" :use-label-slot="true" bg-color="#f9f9f9" :value-style="{position: 'relative'}">
  49. <button open-type="contact" class="cell-btn" slot="label"></button>
  50. <view slot="icon" class="icon kefu"></view>
  51. </u-cell-item>
  52. <u-cell-item title="清除缓存" :border-bottom="false" icon="reload" bg-color="#f9f9f9" @click="handleClearCache">
  53. </u-cell-item>
  54. </u-cell-group>
  55. <view class="qrcode dir-top-wrap cross-center">
  56. <view class="img">
  57. <u-image
  58. width="260"
  59. height="260"
  60. :src="setting.service_qrcode"
  61. ></u-image>
  62. </view>
  63. <text class="title">扫描二维码联系客服</text>
  64. </view>
  65. </view>
  66. <u-modal v-model="modal.show"
  67. :show-cancel-button="true"
  68. content="确定清除缓存?"
  69. cancel-text="取消"
  70. cancel-color="#CCCCCC"
  71. confirm-text="确定"
  72. confirm-color="#046E64"
  73. @confirm="sureClearCache"
  74. >
  75. </u-modal>
  76. </app-layout>
  77. </template>
  78. <script>
  79. import appLayout from "@/components/app-layout"
  80. export default {
  81. components:{
  82. appLayout,
  83. },
  84. data() {
  85. return {
  86. userData: this.vuex_user_data,
  87. setting: {},
  88. modal: {
  89. show : false
  90. }
  91. }
  92. },
  93. methods: {
  94. handleJumpBuy(){
  95. if(this.$platform === 'ios'){
  96. uni.showModal({
  97. title: '提示',
  98. content: '由于相关规范,iOS功能暂不可用',
  99. success: function (res) {
  100. // res.confirm res.cancel
  101. }
  102. });
  103. return false
  104. }else{
  105. this.$jump({url:'/pages/my/member',type:'to'})
  106. }
  107. },
  108. getPhoneNumber(phoneNumber){
  109. if(phoneNumber.detail.errMsg !== 'getPhoneNumber:ok'){
  110. this.$u.toast('已取消');
  111. return
  112. }
  113. uni.checkSession({
  114. success: data => {
  115. this.$u.api.userBindPhone(phoneNumber.detail).then(data => {
  116. this.$u.vuex(this.$const.USER_DATA,data)
  117. this.userData = data;
  118. })
  119. },
  120. fail: err => {
  121. this.sureClearCache()
  122. }
  123. })
  124. },
  125. handleGetInfo(){
  126. let _this = this;
  127. wx.getUserProfile({
  128. desc: '重新获取用户信息',
  129. success: data => {
  130. let params = {
  131. encryptedData: data.encryptedData,
  132. iv: data.iv,
  133. }
  134. _this.$u.api.userUpdate(params).then(res => {
  135. _this.$u.vuex(_this.$const.USER_DATA, res)
  136. this.userData = res;
  137. })
  138. },
  139. fail: err => {
  140. console.log('-->data',err)
  141. _this.$u.toast('获取用户信息失败')
  142. }
  143. });
  144. },
  145. getUser(){
  146. this.$u.api.userGet().then(data => {
  147. console.log('-->data',data)
  148. })
  149. },
  150. getSetting(){
  151. this.$u.api.settingGet().then(data => {
  152. this.setting = data;
  153. })
  154. },
  155. handleClearCache(){
  156. this.modal.show = true
  157. },
  158. sureClearCache(){
  159. this.$u.vuex(this.$const.USER_TOKEN,null)
  160. this.$u.vuex(this.$const.USER_DATA,null)
  161. this.$u.vuex(this.$const.USER_CONFIG,null)
  162. this.$jump({url:'/pages/login/login?redirect=pages/my/index',type:'redirect'})
  163. },
  164. handleCopy(){
  165. this.$util.copyText(this.setting.service_wechat)
  166. }
  167. },
  168. onLoad(){
  169. this.userData = this.vuex_user_data
  170. //this.getUser();
  171. },
  172. onShow(){
  173. this.getSetting();
  174. }
  175. }
  176. </script>
  177. <style lang="scss" scoped>
  178. /deep/.u-cell{
  179. padding: 22rpx 32rpx !important;
  180. }
  181. .cell-btn{
  182. border: 0;
  183. background: transparent;
  184. position: absolute;
  185. height: 80rpx;
  186. top: 0;
  187. width: 86%;
  188. z-index: 0;
  189. &:after{
  190. content: unset;
  191. }
  192. }
  193. .container{
  194. padding: 0;
  195. height: 100vh;
  196. .customer{
  197. position: relative;
  198. .bg{
  199. position: absolute;
  200. background: url("@/static/images/bg.png") no-repeat center;
  201. background-size: 100% 100%;
  202. height: 300rpx;
  203. left: 0;
  204. top: 0;
  205. width: 750rpx;
  206. z-index: 0;
  207. }
  208. .info{
  209. height: 300rpx;
  210. position: relative;
  211. color: #ffffff;
  212. z-index: 1;
  213. .nickname{
  214. margin: 8rpx 0;
  215. font-weight: 600;
  216. }
  217. }
  218. }
  219. .tab-list{
  220. margin-top: 32rpx;
  221. .icon{
  222. width: 32rpx;
  223. height: 32rpx;
  224. background-size: cover;
  225. background-repeat: no-repeat;
  226. background-position: center;
  227. margin-right: 8rpx;
  228. &.bridge{
  229. background-image: url("@/static/images/icons/bridge.png");
  230. }
  231. &.kefu{
  232. background-image: url("@/static/images/icons/kefu.png");
  233. }
  234. &.member{
  235. background-image: url("@/static/images/icons/member.png");
  236. }
  237. &.share{
  238. background-image: url("@/static/images/icons/share.png");
  239. }
  240. &.wechat{
  241. background-image: url("@/static/images/icons/wechat.png");
  242. }
  243. }
  244. }
  245. .qrcode{
  246. margin-top: 32rpx;
  247. >.title{
  248. padding: 8rpx 0;
  249. color: #6e6e6e;
  250. }
  251. }
  252. }
  253. </style>