user.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <template>
  2. <div class="app-main app-content">
  3. <div class="user-wrap">
  4. <!-- 未登录 -->
  5. <template v-if="$util.isEmpty(shopUser)">
  6. <div class="no-login-attr login-attr-wrap">
  7. <img :src="`${constant.imgUrl}/retail/user/attr-default.png`" alt mode="widthFix" />
  8. </div>
  9. <div class="button-wrap">
  10. <!-- #ifdef H5 -->
  11. <button class="button-com" @click="showPopup">申请会员</button>
  12. <!-- #endif -->
  13. <!-- #ifdef MP-WEIXIN -->
  14. <button class="button-com mini-btn" open-type="getUserInfo" @getuserinfo="getWxAvatar">申请会员</button>
  15. <!-- #endif -->
  16. </div>
  17. </template>
  18. <!-- 已登录 -->
  19. <template v-else>
  20. <div class="is-login-attr">
  21. <div class="user-wrap-top">
  22. <div class="user-blo-left">
  23. <div class="user-name-warp">
  24. <div class="user-name">{{ shopUser.userName }}</div>
  25. <div class="user-level-img">
  26. <block v-if="!$util.isEmpty(shopUser)">
  27. <appVipModule v-if="shopUser.member > 0" class="level-img" :text="`VIP${shopUser.member}`" />
  28. <appVipModule v-else-if="shopUser.member == 0" class="level-img" :text="`VIP`" />
  29. <div class="nomal-text" v-else>普通客户</div>
  30. </block>
  31. </div>
  32. </div>
  33. <div class="user-level">
  34. <!-- <div class="user-level-icon">
  35. <img src="" alt />
  36. </div>-->
  37. <div>成长值 {{ shopUser.userAsset.growth }}/{{ shopUser.userAsset.nextLevelGrowth }}</div>
  38. </div>
  39. </div>
  40. <div class="user-blo-right login-attr-wrap">
  41. <img :src="smallAvatarUrl | default_avatar" alt="头像" mode="widthFix" />
  42. </div>
  43. </div>
  44. <div class="user-wrap-bottom">
  45. <!-- <div class="level-lint"></div> -->
  46. <div class="level-lint">
  47. <progress :percent="percentNum" stroke-width="2" activeColor="#ffe4bd" backgroundColor="#FF2842" />
  48. </div>
  49. <div>ID {{ shopUser.id }}</div>
  50. </div>
  51. </div>
  52. </template>
  53. </div>
  54. <template v-if="!$util.isEmpty(shopUser)">
  55. <div class="surplus-wrap">
  56. <div class="surplus-left">
  57. <div>我的余额(¥)</div>
  58. <div class="my-surplus">{{ shopUser.userAsset.balance || 0.00 }}</div>
  59. </div>
  60. <div class="surplus-right">
  61. <button class="button-com" v-if="shopUser.subscribe != 1 || !shopUser.mobile" @click="showPopup">申请会员</button>
  62. <!-- <button class="button-com" v-if="shopUser.isFull != 1" @click="showPopup">申请会员</button> -->
  63. <!-- <button class="button-com mini-btn" open-type="getUserInfo" v-if="loginInfo.isFull != 1" @getuserinfo="getWxAvatar">申请会员</button> -->
  64. <button class="button-com" @click="pageToFn({
  65. url: '/pages/pay/index',
  66. query: {
  67. pageStatus: 'recharge'
  68. }
  69. })">充值</button>
  70. <button class="button-com red" @click="pageToFn({
  71. url: '/pages/pay/index',
  72. query: {
  73. pageStatus: 'payment'
  74. }
  75. })">付款</button>
  76. </div>
  77. </div>
  78. </template>
  79. <div class="list-content">
  80. <tui-list-view class="tui-list-view">
  81. <tui-list-cell class="tui-list" :arrow="true" @click="pageToFn('/pages/order/list')">
  82. <div class="list-wrap">
  83. <div class="list-label">我的订单</div>
  84. <!-- <div class="list-text">{{ shopUser.userAsset.totalBuyNum }}</div> -->
  85. </div>
  86. </tui-list-cell>
  87. <tui-list-cell class="tui-list" :arrow="true" @click="pageToFn('/pages/interest/invite')">
  88. <div class="list-wrap">
  89. <div class="list-label">我的邀请</div>
  90. <div class="list-text">领取奖励</div>
  91. </div>
  92. </tui-list-cell>
  93. <tui-list-cell class="tui-list" :arrow="true" @click="pageToFn('/pages/coupon/list')">
  94. <div class="list-wrap">
  95. <div class="list-label">我的优惠券</div>
  96. </div>
  97. </tui-list-cell>
  98. <tui-list-cell class="tui-list" :arrow="true" @click="pageToFn('/pages/interest/level')">
  99. <div class="list-wrap">
  100. <div class="list-label">会员权益</div>
  101. </div>
  102. </tui-list-cell>
  103. <tui-list-cell class="tui-list" :arrow="true" @click="pageToFn('/pages/user/password')">
  104. <div class="list-wrap">
  105. <div class="list-label">支付密码设置</div>
  106. </div>
  107. </tui-list-cell>
  108. </tui-list-view>
  109. </div>
  110. <div class="list-content">
  111. <tui-list-view class="tui-list-view">
  112. <tui-list-cell class="tui-list" :last="true" @click="logoutFn()">
  113. <div class="list-wrap">
  114. <div class="list-label">退出登录</div>
  115. </div>
  116. </tui-list-cell>
  117. </tui-list-view>
  118. </div>
  119. <!-- 登录弹窗 -->
  120. <login-popup :show="popupShow" :info="wxInfo" :merchantInfo="merchantInfo" :isPublic="isPublic" @hide="hidePopup" />
  121. <!-- 登录弹窗 -->
  122. <app-trademark />
  123. <!-- <app-footer :activeIndex="3" /> -->
  124. <!-- login -->
  125. <go-login :show.sync="loginShow" />
  126. </div>
  127. </template>
  128. <script>
  129. import { mapGetters } from 'vuex'
  130. // import AppFooter from '@/components/app-footer'
  131. import TuiListView from '@/components/plugin/list-view'
  132. import TuiListCell from '@/components/plugin/list-cell'
  133. import LoginPopup from '@/pages/home/components/login-popup'
  134. import AppTrademark from '@/components/module/app-trademark'
  135. import GoLogin from '@/pages/home/components/go-login.vue'
  136. import AppVipModule from '@/components/module/app-vip'
  137. import { getMiniAppUrl, isWxBrowser } from '@/utils/common'
  138. // api
  139. import { getMerchantInfo } from '@/api/common'
  140. import { getShopUser } from '@/utils/auth'
  141. // import { getWxInfo, getWxPhone } from '@/api/mini'
  142. export default {
  143. name: 'user',
  144. components: {
  145. // AppFooter
  146. TuiListView,
  147. TuiListCell,
  148. LoginPopup,
  149. AppTrademark,
  150. GoLogin,
  151. AppVipModule
  152. },
  153. data() {
  154. return {
  155. constant: this.$constant,
  156. popupShow: false,
  157. isPublic: false,
  158. stepIndex: 0,
  159. wxInfo: {},
  160. loginShow: false,
  161. merchantInfo: {}
  162. }
  163. },
  164. computed: {
  165. ...mapGetters({ shopUser: 'getShopUser' }),
  166. // #ifdef MP-WEIXIN
  167. ...mapGetters({ loginInfo: 'getLoginInfo' }),
  168. // #endif
  169. smallAvatarUrl() {
  170. return this.shopUser.smallAvatarUrl || ''
  171. },
  172. percentNum() {
  173. if (this.$util.isEmpty(this.shopUser)) return 0
  174. return Math.round((this.shopUser.userAsset.growth / this.shopUser.userAsset.nextLevelGrowth) * 100)
  175. }
  176. },
  177. onLoad(option) {
  178. // this.init()
  179. },
  180. methods: {
  181. init() {
  182. getShopUser().then(res => {
  183. if (this.option.scan == 1 && res.isFull != 1) {
  184. this.isPublic = true
  185. this.popupShow = true
  186. }
  187. })
  188. getMerchantInfo().then(res => {
  189. this.merchantInfo = res.data
  190. })
  191. },
  192. // pageTo
  193. pageToFn(item) {
  194. if (this.$util.isLogin()) {
  195. this.$util.pageTo(item)
  196. } else {
  197. this.loginShow = true
  198. }
  199. },
  200. showPopup() {
  201. // this.popupShow = true
  202. // #ifdef H5
  203. this.pageTo('/pages/user/register')
  204. // if (isWxBrowser()) {
  205. // location.href = `${this.$constant.hostUrl}/auth/prepare?url=${encodeURIComponent(getMiniAppUrl(this.option, true))}`
  206. // }
  207. // this.$util.getCheckLogin()
  208. // #endif
  209. // #ifdef MP-WEIXIN
  210. this.popupShow = true
  211. // #endif
  212. },
  213. hidePopup() {
  214. this.popupShow = false
  215. },
  216. logoutFn() {
  217. uni.clearStorageSync()
  218. // #ifdef H5
  219. // location.reload()
  220. this.$util.pageTo({
  221. url: '/pages/home/index',
  222. type: 4
  223. })
  224. // #endif
  225. // #ifndef H5
  226. this.$util.pageTo({
  227. url: '/pages/home/index',
  228. type: 4
  229. })
  230. // #endif
  231. }
  232. // 获取微信信息
  233. // getWxAvatar() {
  234. // uni.getUserInfo({
  235. // provider: 'weixin',
  236. // success: res => {
  237. // console.log('res', res)
  238. // // this.popupShow = true
  239. // getWxInfo({ iv: res.iv, encryptedData: res.encryptedData }).then(subRes => {
  240. // console.log('用户信息', subRes)
  241. // this.wxInfo = subRes.data
  242. // this.popupShow = true
  243. // })
  244. // },
  245. // fail: () => {
  246. // // this.loading = false
  247. // }
  248. // })
  249. // }
  250. }
  251. }
  252. </script>
  253. <style lang="scss" scoped>
  254. .user-wrap {
  255. height: 220px;
  256. background-image: url('../../static/images/user/bg.png');
  257. background-repeat: no-repeat;
  258. background-size: 100% 100%;
  259. padding-top: 42px;
  260. color: #f5e5e5;
  261. .login-attr-wrap {
  262. width: 90px;
  263. height: 90px;
  264. border-radius: 50%;
  265. img {
  266. border-radius: 50%;
  267. }
  268. }
  269. .no-login-attr {
  270. margin: 0 auto;
  271. margin-bottom: 12px;
  272. }
  273. .is-login-attr {
  274. padding: 0 20px 0 48px;
  275. .user-wrap-top {
  276. @include disFlex(center, space-between);
  277. .user-name-warp {
  278. @include disFlex(center, flex-start);
  279. margin-bottom: 16px;
  280. .user-name {
  281. font-size: 36px;
  282. font-weight: 600;
  283. color: #fff;
  284. margin-right: 20px;
  285. }
  286. .level-img {
  287. /deep/.vip-text {
  288. top: 4px;
  289. left: 42px;
  290. transform: scale(0.8);
  291. }
  292. }
  293. .nomal-text {
  294. font-size: 24px;
  295. padding: 2px 16px;
  296. color: #f7f7f7;
  297. border: 1px solid #f7f7f7;
  298. display: inline-block;
  299. border-radius: 50px;
  300. }
  301. }
  302. .user-level {
  303. @include disFlex(center, flex-start);
  304. }
  305. .user-blo-right {
  306. margin-right: 30px;
  307. }
  308. }
  309. .user-wrap-bottom {
  310. .level-lint {
  311. border-bottom: 4px solid $mainColor;
  312. border-radius: 4px;
  313. margin-top: 20px;
  314. margin-bottom: 10px;
  315. position: relative;
  316. // &::before {
  317. // position: absolute;
  318. // top: 0;
  319. // left: 0;
  320. // display: inline-block;
  321. // content: '';
  322. // background-color: #ffe4bd;
  323. // width: 200px;
  324. // height: 4px;
  325. // border-radius: 4px;
  326. // }
  327. }
  328. }
  329. }
  330. .button-wrap {
  331. @include disFlex(center, center);
  332. .mini-btn {
  333. border: none !important;
  334. }
  335. }
  336. }
  337. .surplus-wrap {
  338. @include disFlex(flex-end, space-between);
  339. padding: 10px 40px 34px;
  340. background-color: #fff;
  341. .surplus-left {
  342. color: $fontColor3;
  343. .my-surplus {
  344. font-size: 46px;
  345. margin-top: 14px;
  346. color: #333;
  347. font-weight: bold;
  348. }
  349. }
  350. .surplus-right {
  351. margin-bottom: 10px;
  352. .button-com {
  353. margin-left: 20px;
  354. }
  355. }
  356. }
  357. .list-content {
  358. margin-bottom: 20px;
  359. // padding: 0 20px;
  360. background-color: #fff;
  361. .tui-list-cell {
  362. padding-left: 50px;
  363. padding-right: 50px;
  364. }
  365. .list-wrap {
  366. @include disFlex(center, space-between);
  367. width: calc(100% - 30px);
  368. padding-right: 30px;
  369. .list-text {
  370. color: $fontColor3;
  371. }
  372. }
  373. }
  374. </style>