userInfor.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. <template>
  2. <view :style="[componentStyle]">
  3. <view class="userInfor" :style="[userInfoStyle]" @click="goLogin">
  4. <view class="left acea-row row-middle">
  5. <view class="pictrue acea-row row-center-wrapper relative">
  6. <image :src="diyInfo.avatar" v-if="diyInfo.avatar && isLogin"></image>
  7. <image src="@/static/images/king.png" class="king" v-if="diyInfo.is_money_level"></image>
  8. <image v-if="!diyInfo.avatar && isLogin" :src="dataConfig.logoConfig.url || '@/static/images/f.png'"></image>
  9. <image v-if="!isLogin" :src="dataConfig.logoConfig.url || '@/static/images/f.png'"></image>
  10. </view>
  11. <view class="text">
  12. <view v-if="!isLogin" class="name">{{ $t(`请点击登录`) }}</view>
  13. <view v-else class="name acea-row row-middle">
  14. <view class="nameCon line1">{{ diyInfo.nickname }}</view>
  15. <view class="lable" v-if="diyInfo.level>0" :style="[lableStyle]">
  16. <text class="iconfont icon-ic_crown1"></text>
  17. {{ diyInfo.vip_name }}
  18. </view>
  19. </view>
  20. <view class="acea-row row-middle" v-if="isLogin && diyInfo.level>0">
  21. <view class="progress" :style="[progressStyle]">
  22. <view class="bg-reds" :style="[bgRedsStyle]">
  23. </view>
  24. </view>
  25. <view class="percent">{{diyInfo.exp?diyInfo.exp.split('.')[0]:0}} {{diyInfo.next_exp ? `/ ${diyInfo.next_exp}` : ''}}</view>
  26. </view>
  27. <view class="phone acea-row row-middle" v-if="isLogin && diyInfo.level<=0 && diyInfo.phone">
  28. <text>{{diyInfo.phone}}</text>
  29. </view>
  30. </view>
  31. <view v-if="isLogin" class="right acea-row row-bottom">
  32. <template v-if="dataConfig.styleConfig.tabVal == 1">
  33. <view class="item" v-if="checkType.indexOf(1) > -1" @click.stop="goIntegral">
  34. <view class="num">{{diyInfo.integral||0}}</view>
  35. <view>{{ $t(`积分`) }}</view>
  36. </view>
  37. <view class="item" v-if="checkType.indexOf(2) > -1" @click.stop="goMoney">
  38. <view class="num">{{diyInfo.now_money||0}}</view>
  39. <view>{{ $t(`余额`) }}</view>
  40. </view>
  41. <view class="item" v-if="checkType.indexOf(0) > -1" @click.stop="goCoupon">
  42. <view class="num">{{diyInfo.couponCount||0}}</view>
  43. <view>{{ $t(`优惠券`) }}</view>
  44. </view>
  45. <view class="item" v-if="checkType.indexOf(4) > -1" @click.stop="goCollection">
  46. <view class="num">{{diyInfo.collectCount||0}}</view>
  47. <view>{{ $t(`收藏`) }}</view>
  48. </view>
  49. <view class="item" v-if="checkType.indexOf(5) > -1" @click.stop="goVisit">
  50. <view class="num">{{diyInfo.visit_num||0}}</view>
  51. <view>{{ $t(`浏览`) }}</view>
  52. </view>
  53. </template>
  54. </view>
  55. </view>
  56. <view v-if="dataConfig.styleConfig.tabVal == 0 && isLogin" class="bottom acea-row row-middle">
  57. <view v-if="checkType.indexOf(1) != -1" class="item" @click.stop="goIntegral">
  58. <view class="num">{{diyInfo.integral||0}}</view>
  59. <view>{{ $t(`积分`) }}</view>
  60. </view>
  61. <view v-if="checkType.indexOf(2) != -1" class="item" @click.stop="goMoney">
  62. <view class="num">{{diyInfo.now_money||0}}</view>
  63. <view>{{ $t(`余额`) }}</view>
  64. </view>
  65. <view v-if="checkType.indexOf(0) != -1" class="item" @click.stop="goCoupon">
  66. <view class="num">{{diyInfo.coupon_num||0}}</view>
  67. <view>{{ $t(`优惠券`) }}</view>
  68. </view>
  69. <view v-if="checkType.indexOf(4) != -1" class="item" @click.stop="goCollection">
  70. <view class="num">{{diyInfo.collectCount||0}}</view>
  71. <view>{{ $t(`收藏`) }}</view>
  72. </view>
  73. <view v-if="checkType.indexOf(5) != -1" class="item" @click.stop="goVisit">
  74. <view class="num">{{diyInfo.visit_num||0}}</view>
  75. <view>{{ $t(`浏览`) }}</view>
  76. </view>
  77. </view>
  78. <!-- <view class="codePopup" :style="colorStyle" v-show="isCode">
  79. <view class="header acea-row row-between-wrapper">
  80. <view class="title" :class="{'on': codeIndex == index,'onLeft':codeIndex == 1}" v-for="(item, index) in codeList" :key="index" @click="tapCode(index)">{{item.name}}</view>
  81. </view>
  82. <view>
  83. <view class="acea-row row-center-wrapper">
  84. <w-barcode :options="config.bar"></w-barcode>
  85. </view>
  86. <view class="acea-row row-center-wrapper" style="margin-top: 35rpx;">
  87. <w-qrcode :options="config.qrc" @generate="hello"></w-qrcode>
  88. </view>
  89. <view class="codeNum">{{config.bar.code}}</view>
  90. <view class="tip">如遇到扫码失败请将屏幕调至最亮重新扫码</view>
  91. </view>
  92. <view class="iconfont icon-guanbi2" @click="closeCode"></view>
  93. </view> -->
  94. <!-- <view class="mark" v-if="isCode"></view> -->
  95. </view>
  96. </view>
  97. </template>
  98. <script>
  99. import colors from "@/mixins/color";
  100. import {
  101. getlevelInfo,
  102. getRandCode,
  103. getUserInfo
  104. } from '@/api/user.js';
  105. import {
  106. mapGetters
  107. } from 'vuex';
  108. export default {
  109. computed: {
  110. ...mapGetters(['isLogin']),
  111. lableStyle() {
  112. let styleObject = {
  113. 'background': this.currentLevelColor,
  114. 'color': this.currentLevelColor,
  115. };
  116. return styleObject;
  117. },
  118. componentStyle() {
  119. return {
  120. 'padding': `${this.dataConfig.topConfig.val * 2}rpx ${this.dataConfig.prConfig.val * 2}rpx ${this.dataConfig.bottomConfig.val * 2}rpx`,
  121. 'margin-top': `${this.dataConfig.mbConfig.val * 2}rpx`,
  122. 'background': this.dataConfig.bottomBgColor.color[0].item,
  123. };
  124. },
  125. progressStyle() {
  126. let styleObject = {};
  127. if (this.dataConfig.toneConfig.tabVal) {
  128. styleObject['background'] = this.dataConfig.progressBgColor.color[0].item;
  129. }
  130. return styleObject;
  131. },
  132. bgRedsStyle() {
  133. let diyInfo = this.diyInfo;
  134. let styleObject = {
  135. 'width': `${diyInfo.exp>diyInfo.next_exp?100:(this.$util.$h.Div(parseInt(diyInfo.exp), diyInfo.next_exp)*100 >=5? this.$util.$h.Div(parseInt(diyInfo.exp), diyInfo.next_exp)*100:5)}%`,
  136. };
  137. if (this.dataConfig.toneConfig.tabVal) {
  138. styleObject['background'] = `linear-gradient(90deg, ${this.dataConfig.progressColor.color[0].item} 0%, ${this.dataConfig.progressColor.color[1].item} 100%)`;
  139. }
  140. return styleObject;
  141. },
  142. userInfoStyle() {
  143. let borderRadius = `${this.dataConfig.fillet.val * 2}rpx`;
  144. if (this.dataConfig.fillet.type) {
  145. borderRadius =
  146. `${this.dataConfig.fillet.valList[0].val * 2}rpx ${this.dataConfig.fillet.valList[1].val * 2}rpx ${this.dataConfig.fillet.valList[3].val * 2}rpx ${this.dataConfig.fillet.valList[2].val * 2}rpx`;
  147. }
  148. return {
  149. 'border-radius': borderRadius,
  150. 'background': `linear-gradient(90deg, ${this.dataConfig.moduleColor.color[0].item} 0%, ${this.dataConfig.moduleColor.color[1].item} 100%)`,
  151. };
  152. },
  153. },
  154. name: 'userInfor',
  155. props: {
  156. dataConfig: {
  157. type: Object,
  158. default: () => {}
  159. },
  160. isSortType: {
  161. type: String | Number,
  162. default: 0
  163. }
  164. },
  165. mixins: [colors],
  166. data() {
  167. return {
  168. config: {
  169. bar: {
  170. code: '',
  171. color: ['#000'],
  172. bgColor: '#FFFFFF', // 背景色
  173. width: 480, // 宽度
  174. height: 110 // 高度
  175. },
  176. qrc: {
  177. code: '',
  178. size: 380, // 二维码大小
  179. level: 3, //等级 0~4
  180. bgColor: '#FFFFFF', //二维码背景色 默认白色
  181. border: {
  182. color: ['#eee', '#eee'], //边框颜色支持渐变色
  183. lineWidth: 3, //边框宽度
  184. },
  185. // img: '/static/logo.png', //图片
  186. // iconSize: 40, //二维码图标的大小
  187. color: ['#333', '#333'], //边框颜色支持渐变色
  188. }
  189. },
  190. codeList: [{
  191. name: '会员码'
  192. }, {
  193. name: '付款码'
  194. }],
  195. codeIndex: 0,
  196. isCode: false,
  197. bgColor: '',
  198. textColor: '',
  199. progressColor: this.dataConfig.progressColor.color,
  200. mbCongfig: 0,
  201. prConfig: 0, //背景边距
  202. itemStyle: 0,
  203. checkType: this.dataConfig.checkboxInfo.type,
  204. diyInfo: {},
  205. currentLevelColor: '',
  206. }
  207. },
  208. created() {
  209. if (this.isLogin) {
  210. this.getDiyUserInfo();
  211. this.getlevelInfo();
  212. }
  213. },
  214. watch: {
  215. isLogin: {
  216. handler: function(newV, oldV) {
  217. if (newV) {
  218. this.getDiyUserInfo();
  219. }
  220. },
  221. deep: true
  222. }
  223. },
  224. methods: {
  225. getCode() {
  226. getRandCode().then(res => {
  227. let code = res.data.code;
  228. this.config.bar.code = code;
  229. this.config.qrc.code = code;
  230. }).catch(err => {
  231. return this.$util.Tips(err);
  232. })
  233. },
  234. tapQrCode() {
  235. // this.isCode = true;
  236. // this.codeIndex = 0;
  237. // this.$nextTick(function() {
  238. // let code = this.diyInfo.bar_code;
  239. // this.config.bar.code = code;
  240. // this.config.qrc.code = code;
  241. // })
  242. uni.navigateTo({
  243. url: '/pages/users/user_member_code/index'
  244. })
  245. },
  246. closeCode() {
  247. this.isCode = false
  248. this.isextension = false
  249. },
  250. tapCode(index) {
  251. this.codeIndex = index;
  252. if (index == 1) {
  253. this.getCode();
  254. } else {
  255. let code = this.diyInfo.bar_code;
  256. this.config.bar.code = code;
  257. this.config.qrc.code = code;
  258. }
  259. },
  260. goIntegral() {
  261. uni.navigateTo({
  262. url: '/pages/users/user_integral/index'
  263. })
  264. },
  265. goMoney() {
  266. uni.navigateTo({
  267. url: '/pages/users/user_money/index'
  268. })
  269. },
  270. goCollection() {
  271. uni.navigateTo({
  272. url: '/pages/users/user_goods_collection/index'
  273. })
  274. },
  275. goVisit() {
  276. uni.navigateTo({
  277. url: '/pages/users/visit_list/index'
  278. })
  279. },
  280. goCoupon() {
  281. uni.navigateTo({
  282. url: '/pages/users/user_coupon/index'
  283. })
  284. },
  285. goLogin() {
  286. if (!this.isLogin) {
  287. this.$emit('changeLogin');
  288. }
  289. },
  290. getDiyUserInfo() {
  291. getUserInfo().then(res => {
  292. this.diyInfo = res.data;
  293. }).catch(err => {
  294. this.$util.Tips({
  295. title: err
  296. });
  297. })
  298. },
  299. getlevelInfo() {
  300. getlevelInfo().then(res => {
  301. const {
  302. level_info,
  303. level_list
  304. } = res.data;
  305. const currentLevel = level_list.find(item => item.grade == level_info.grade);
  306. if (currentLevel) {
  307. this.currentLevelColor = currentLevel.color;
  308. }
  309. });
  310. },
  311. colorToRgba(str, n) {
  312. // 十六进制颜色值的正则表达式
  313. const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
  314. let sColor = str.toLowerCase();
  315. // 十六进制颜色转换为RGB格式
  316. if (sColor && reg.test(sColor)) {
  317. if (sColor.length === 4) {
  318. let sColorNew = '#';
  319. for (let i = 1; i < 4; i += 1) {
  320. sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
  321. }
  322. sColor = sColorNew;
  323. }
  324. // 处理六位颜色值
  325. const sColorChange = [];
  326. for (let k = 1; k < 7; k += 2) {
  327. sColorChange.push(parseInt(`0x${sColor.slice(k, k + 2)}`, 16));
  328. }
  329. return `rgba(${sColorChange.join(',')}, ${n})`;
  330. }
  331. return sColor;
  332. },
  333. }
  334. }
  335. </script>
  336. <style lang="scss">
  337. .userInfor {
  338. // flex: 1;
  339. // padding: 28rpx 20rpx;
  340. background: #FFFFFF;
  341. .mark {
  342. position: fixed;
  343. top: 0;
  344. left: 0;
  345. bottom: 0;
  346. right: 0;
  347. background: rgba(0, 0, 0, 0.5);
  348. z-index: 50;
  349. }
  350. .codePopup .icon-guanbi2 {
  351. margin-top: 75rpx !important;
  352. }
  353. &.pageOn {
  354. border-radius: 12rpx;
  355. }
  356. .right {
  357. position: relative;
  358. &::before {
  359. content: "";
  360. position: absolute;
  361. top: 0;
  362. right: 20rpx;
  363. left: 20rpx;
  364. border-top: 1rpx solid #EEEEEE;
  365. }
  366. .item {
  367. flex: 1;
  368. min-width: 0;
  369. padding: 34rpx 0;
  370. margin: 0;
  371. font-size: 26rpx;
  372. line-height: 36rpx;
  373. color: #999999;
  374. .num {
  375. font-family: SemiBold;
  376. font-weight: 500;
  377. font-size: 28rpx;
  378. margin-left: 8rpx;
  379. color: #333333;
  380. }
  381. }
  382. .iconfont {
  383. font-size: 40rpx;
  384. margin-bottom: 8rpx;
  385. }
  386. }
  387. .left {
  388. padding: 32rpx 20rpx;
  389. .pictrue {
  390. width: 90rpx;
  391. height: 90rpx;
  392. border: 1px solid #EEEEEE;
  393. border-radius: 50%;
  394. margin-right: 20rpx;
  395. image {
  396. width: 100%;
  397. height: 100%;
  398. border-radius: 50%;
  399. }
  400. .king{
  401. width: 36rpx;
  402. height: 36rpx;
  403. position: absolute;
  404. top:-18rpx;
  405. right: -8rpx;
  406. }
  407. }
  408. .text {
  409. flex: 1;
  410. font-weight: 400;
  411. //color: #333333;
  412. font-size: 28rpx;
  413. .name {
  414. margin-bottom: 8rpx;
  415. .nameCon {
  416. max-width: 190rpx;
  417. font-weight: bold;
  418. }
  419. .lable {
  420. height: 32rpx;
  421. padding: 0 8rpx;
  422. border-radius: 16rpx;
  423. margin-left: 8rpx;
  424. font-weight: 500;
  425. font-size: 20rpx;
  426. line-height: 32rpx;
  427. .iconfont {
  428. margin-right: 4rpx;
  429. font-size: 20rpx;
  430. }
  431. }
  432. }
  433. .progress {
  434. overflow: hidden;
  435. background-color: #EEEEEE;
  436. width: 120rpx;
  437. height: 14rpx;
  438. border-radius: 7rpx;
  439. position: relative;
  440. margin-right: 8rpx;
  441. .bg-reds {
  442. width: 0;
  443. height: 14rpx;
  444. border-radius: 7rpx;
  445. transition: width 0.6s ease;
  446. background: linear-gradient(90deg, var(--view-theme) 0%, var(--view-gradient) 100%);
  447. }
  448. }
  449. .percent {
  450. font-size: 20rpx;
  451. line-height: 20rpx;
  452. color: #666666;
  453. }
  454. .phone {
  455. font-weight: 400;
  456. //color: #666666;
  457. font-size: 20rpx;
  458. margin-top: 6rpx;
  459. .icon-shouji2 {
  460. margin-right: 4rpx;
  461. font-size: 20rpx;
  462. }
  463. }
  464. }
  465. .right::before {
  466. display: none;
  467. }
  468. .item {
  469. width: 108rpx;
  470. padding: 0;
  471. overflow: hidden;
  472. text-align: center;
  473. font-size: 22rpx;
  474. color: #999999;
  475. .num {
  476. margin: 0 0 12rpx;
  477. font-size: 32rpx;
  478. }
  479. .iconfont {
  480. font-weight: 500;
  481. color: #333333;
  482. font-size: 40rpx;
  483. margin: 0 0 12rpx;
  484. }
  485. }
  486. }
  487. .bottom {
  488. position: relative;
  489. &::before {
  490. content: "";
  491. position: absolute;
  492. top: 0;
  493. right: 20rpx;
  494. left: 20rpx;
  495. border-top: 1px solid #EEEEEE;
  496. }
  497. .item {
  498. flex: 1;
  499. padding: 42rpx 0 40rpx;
  500. text-align: center;
  501. font-weight: 500;
  502. font-size: 22rpx;
  503. line-height: 30rpx;
  504. color: #999999;
  505. }
  506. .num {
  507. margin: 0 0 12rpx;
  508. font-family: SemiBold;
  509. font-weight: 500;
  510. font-size: 32rpx;
  511. line-height: 32rpx;
  512. color: #333333;
  513. }
  514. }
  515. }
  516. </style>