userinfo-card.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <view>
  3. <view class="sh-userinfo-box">
  4. <view class="head-wrap" :style="{ background: detail.image ? `url(${detail.image}) no-repeat center / 100% 100%` : detail.color }">
  5. <!-- 标题栏 -->
  6. <shopro-navbar
  7. backIconName=""
  8. backText="我的"
  9. :backTextStyle="{
  10. color: '#fff',
  11. fontSize: '40rpx',
  12. fontWeight: '500'
  13. }"
  14. :background="navBackground"
  15. >
  16. <view slot="right" class="u-flex u-row-center u-col-center u-m-r-20" v-if="userOtherData.is_store" @tap="goStore">
  17. <button class="u-reset-button merchant-btn">切换商家版</button>
  18. </view>
  19. </shopro-navbar>
  20. <view class="user-head u-flex u-row-between">
  21. <view class="u-flex">
  22. <!-- 个人信息 -->
  23. <view class="info-box">
  24. <view class="u-flex" @tap="$Router.push('/pages/user/info')">
  25. <view class="head-img-wrap">
  26. <image class="head-img" :src="userInfo.avatar || $IMG_URL + '/imgs/base_avatar.png'" mode="aspectFill"></image>
  27. <!-- 同步信息 -->
  28. <block v-if="showRefresh">
  29. <button @tap.stop="showModal = true" class="u-reset-button u-flex u-row-center u-col-center refresh-btn">
  30. <view class="u-iconfont uicon-reload" style="color: #fff;font-size: 24rpx;"></view>
  31. </button>
  32. </block>
  33. </view>
  34. <text class="user-name u-ellipsis-1">{{ userInfo.nickname || '请登录~' }}</text>
  35. </view>
  36. </view>
  37. <!-- 等级 -->
  38. <view v-if="userInfo.group" class="grade-tag tag-box u-flex">
  39. <image v-if="userInfo.group.image" class="tag-img" :src="userInfo.group.image" mode=""></image>
  40. <text class="tag-title">{{ userInfo.group.name }}</text>
  41. </view>
  42. </view>
  43. <view class="u-flex" v-if="userInfo.nickname">
  44. <button class=" u-reset-button code-btn" @tap="onShare"><text class="iconfont icon-qrcode"></text></button>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <!-- 绑定手机 -->
  50. <view class="notice-box u-flex u-row-between u-p-30" v-if="userInfo.verification && !userInfo.verification.mobile" @tap="bindMobile">
  51. <view class="notice-detail">点击绑定手机号,确保账户安全</view>
  52. <button class="u-reset-button bindPhone">去绑定</button>
  53. </view>
  54. <!-- 更新信息 -->
  55. <view class="cu-modal" :class="{ show: showModal }" @tap="showModal = false">
  56. <view class="cu-dialog" style="width: 600rpx;">
  57. <view class="modal-box">
  58. <view class="modal-head">提示</view>
  59. <view class="modal-content">更新微信信息?</view>
  60. <view class="modal-bottom u-flex u-col-center">
  61. <button class="u-reset-button modal-btn cancel-btn" :hover-stay-time="100" hover-class="btn-hover" @tap="showModal = false">取消</button>
  62. <button class="u-reset-button modal-btn save-btn" :hover-stay-time="100" hover-class="btn-hover" @tap="refreshWechatUser">确定</button>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. /**
  71. * 自定义之个人信息
  72. * @property {Object} detail - 个人信息
  73. */
  74. import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
  75. import wechat from '@/shopro/wechat/wechat';
  76. export default {
  77. components: {},
  78. data() {
  79. return {
  80. showModal: false,
  81. platform: this.$platform.get(), //当前平台。
  82. isFixed: false,
  83. navBackground: {
  84. background: 'none'
  85. }
  86. };
  87. },
  88. mounted() {},
  89. props: {
  90. detail: {},
  91. scrollTop: {
  92. type: Number,
  93. default: 0
  94. }
  95. },
  96. watch: {
  97. scrollTop(val) {
  98. let backgroundText = this.detail.image ? `url(${this.detail.image})` : this.detail.color;
  99. this.isFixed = val > 50 ? true : false;
  100. this.navBackground.background = val > 50 ? backgroundText : 'none';
  101. }
  102. },
  103. computed: {
  104. ...mapGetters(['isLogin', 'userInfo', 'userOtherData']),
  105. showRefresh() {
  106. if (this.isLogin) {
  107. if (this.platform === 'wxOfficialAccount') {
  108. return this.userInfo.verification?.wxOfficialAccount;
  109. }
  110. if (this.platform === 'wxMiniProgram') {
  111. return this.userInfo.verification.wxMiniProgram;
  112. }
  113. if (this.platform === 'App') {
  114. return this.userInfo.verification.wxOpenPlatform;
  115. }
  116. }
  117. return false;
  118. }
  119. },
  120. methods: {
  121. ...mapActions(['getUserInfo', 'showAuthModal']),
  122. jump(path, query) {
  123. this.$Router.push({
  124. path: path,
  125. query: query
  126. });
  127. },
  128. // 点击分享
  129. onShare() {
  130. this.$emit('onShare');
  131. },
  132. // 同步用户信息
  133. async refreshWechatUser() {
  134. this.showModal = false;
  135. let token = await wechat.refresh();
  136. token && this.getUserInfo(token);
  137. },
  138. // 跳转门店
  139. goStore() {
  140. if (this.userOtherData.store_id) {
  141. uni.setStorageSync('storeId', this.userOtherData.store_id);
  142. this.jump('/pages/app/merchant/index', { storeId: this.userOtherData.store_id });
  143. } else {
  144. if (uni.getStorageSync('storeId')) {
  145. this.jump('/pages/app/merchant/index');
  146. } else {
  147. this.jump('/pages/app/merchant/list');
  148. }
  149. }
  150. // #ifdef MP-WEIXIN
  151. this.$store.commit('subscribeMessage', 'store');
  152. // #endif
  153. },
  154. // 绑定手机号
  155. bindMobile() {
  156. this.showAuthModal('bindMobile');
  157. }
  158. }
  159. };
  160. </script>
  161. <style lang="scss">
  162. // 更新信息
  163. .modal-box {
  164. width: 600rpx;
  165. .btn-hover {
  166. background-color: rgb(230, 230, 230);
  167. }
  168. .modal-head {
  169. padding-top: 48rpx;
  170. font-weight: 500;
  171. text-align: center;
  172. color: $u-main-color;
  173. }
  174. .modal-content {
  175. padding: 48rpx;
  176. font-size: 30rpx;
  177. text-align: center;
  178. color: $u-content-color;
  179. }
  180. .modal-bottom {
  181. .modal-btn {
  182. flex: 1;
  183. height: 100rpx;
  184. line-height: 100rpx;
  185. font-size: 32rpx;
  186. box-sizing: border-box;
  187. cursor: pointer;
  188. text-align: center;
  189. border-radius: 4rpx;
  190. }
  191. .cancel-btn {
  192. color: #666666;
  193. }
  194. .save-btn {
  195. color: #e9b461;
  196. }
  197. }
  198. }
  199. .sh-userinfo-box {
  200. position: relative;
  201. height: calc(var(--status-bar-height) + 300rpx);
  202. .head-wrap {
  203. powidth: 100%;
  204. height: 100%;
  205. .merchant-btn {
  206. width: 178rpx;
  207. height: 64rpx;
  208. line-height: 64rpx;
  209. background: #ffffff;
  210. border-radius: 32rpx;
  211. font-size: 26rpx;
  212. font-weight: 500;
  213. color: #a8700d;
  214. }
  215. }
  216. .user-head {
  217. width: 100%;
  218. padding-top: 30rpx;
  219. .info-box {
  220. padding-left: 30rpx;
  221. .head-img-wrap {
  222. position: relative;
  223. .refresh-btn {
  224. position: absolute;
  225. padding: 0;
  226. background: none;
  227. width: 40rpx;
  228. height: 40rpx;
  229. border-radius: 50%;
  230. background: #c9912c;
  231. top: -10rpx;
  232. right: 10rpx;
  233. }
  234. }
  235. .head-img {
  236. width: 94rpx;
  237. height: 94rpx;
  238. border-radius: 50%;
  239. background: #ccc;
  240. margin-right: 25rpx;
  241. overflow: hidden;
  242. }
  243. .user-name {
  244. font-size: 30rpx;
  245. font-weight: 500;
  246. color: #fff;
  247. line-height: 30rpx;
  248. width: 180rpx;
  249. }
  250. }
  251. .tag-box {
  252. background: rgba(0, 0, 0, 0.2);
  253. border-radius: 22rpx;
  254. margin-left: 10rpx;
  255. .tag-img {
  256. width: 40rpx;
  257. height: 40rpx;
  258. display: inline-block;
  259. border-radius: 50%;
  260. }
  261. .tag-title {
  262. font-size: 20rpx;
  263. font-weight: 500;
  264. color: rgba(255, 255, 255, 1);
  265. line-height: 40rpx;
  266. padding: 0 10rpx;
  267. }
  268. }
  269. .code-btn {
  270. padding: 30rpx;
  271. .icon-qrcode {
  272. font-size: 50rpx;
  273. color: #fff;
  274. }
  275. }
  276. }
  277. .wallet {
  278. font-size: 20rpx;
  279. padding-left: 140rpx;
  280. .money {
  281. margin-right: 40rpx;
  282. }
  283. }
  284. }
  285. // 绑定微信公众号
  286. .notice-box {
  287. width: 750rpx;
  288. height: 70rpx;
  289. background: rgba(253, 239, 216, 1);
  290. padding: 0 35rpx;
  291. .notice-detail {
  292. font-size: 24rpx;
  293. font-weight: 400;
  294. color: rgba(204, 149, 59, 1);
  295. }
  296. .bindPhone {
  297. width: 135rpx;
  298. line-height: 52rpx;
  299. background: linear-gradient(90deg, rgba(233, 180, 97, 1), rgba(238, 204, 137, 1));
  300. border-radius: 26rpx;
  301. padding: 0;
  302. font-size: 26rpx;
  303. font-weight: 500;
  304. color: rgba(255, 255, 255, 1);
  305. }
  306. }
  307. </style>