userInfor.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  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. hello(res) {
  226. },
  227. getCode() {
  228. getRandCode().then(res => {
  229. let code = res.data.code;
  230. this.config.bar.code = code;
  231. this.config.qrc.code = code;
  232. }).catch(err => {
  233. return this.$util.Tips(err);
  234. })
  235. },
  236. tapQrCode() {
  237. // this.isCode = true;
  238. // this.codeIndex = 0;
  239. // this.$nextTick(function() {
  240. // let code = this.diyInfo.bar_code;
  241. // this.config.bar.code = code;
  242. // this.config.qrc.code = code;
  243. // })
  244. uni.navigateTo({
  245. url: '/pages/users/user_member_code/index'
  246. })
  247. },
  248. closeCode() {
  249. this.isCode = false
  250. this.isextension = false
  251. },
  252. tapCode(index) {
  253. this.codeIndex = index;
  254. if (index == 1) {
  255. this.getCode();
  256. } else {
  257. let code = this.diyInfo.bar_code;
  258. this.config.bar.code = code;
  259. this.config.qrc.code = code;
  260. }
  261. },
  262. goIntegral() {
  263. uni.navigateTo({
  264. url: '/pages/users/user_integral/index'
  265. })
  266. },
  267. goMoney() {
  268. uni.navigateTo({
  269. url: '/pages/users/user_money/index'
  270. })
  271. },
  272. goCollection() {
  273. uni.navigateTo({
  274. url: '/pages/users/user_goods_collection/index'
  275. })
  276. },
  277. goVisit() {
  278. uni.navigateTo({
  279. url: '/pages/users/visit_list/index'
  280. })
  281. },
  282. goCoupon() {
  283. uni.navigateTo({
  284. url: '/pages/users/user_coupon/index'
  285. })
  286. },
  287. goLogin() {
  288. if (!this.isLogin) {
  289. this.$emit('changeLogin');
  290. }
  291. },
  292. getDiyUserInfo() {
  293. getUserInfo().then(res => {
  294. this.diyInfo = res.data;
  295. }).catch(err => {
  296. this.$util.Tips({
  297. title: err
  298. });
  299. })
  300. },
  301. getlevelInfo() {
  302. getlevelInfo().then(res => {
  303. const {
  304. level_info,
  305. level_list
  306. } = res.data;
  307. const currentLevel = level_list.find(item => item.grade == level_info.grade);
  308. if (currentLevel) {
  309. this.currentLevelColor = currentLevel.color;
  310. }
  311. });
  312. },
  313. colorToRgba(str, n) {
  314. // 十六进制颜色值的正则表达式
  315. const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
  316. let sColor = str.toLowerCase();
  317. // 十六进制颜色转换为RGB格式
  318. if (sColor && reg.test(sColor)) {
  319. if (sColor.length === 4) {
  320. let sColorNew = '#';
  321. for (let i = 1; i < 4; i += 1) {
  322. sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
  323. }
  324. sColor = sColorNew;
  325. }
  326. // 处理六位颜色值
  327. const sColorChange = [];
  328. for (let k = 1; k < 7; k += 2) {
  329. sColorChange.push(parseInt(`0x${sColor.slice(k, k + 2)}`, 16));
  330. }
  331. return `rgba(${sColorChange.join(',')}, ${n})`;
  332. }
  333. return sColor;
  334. },
  335. }
  336. }
  337. </script>
  338. <style lang="scss">
  339. .userInfor {
  340. // flex: 1;
  341. // padding: 28rpx 20rpx;
  342. background: #FFFFFF;
  343. .mark {
  344. position: fixed;
  345. top: 0;
  346. left: 0;
  347. bottom: 0;
  348. right: 0;
  349. background: rgba(0, 0, 0, 0.5);
  350. z-index: 50;
  351. }
  352. .codePopup .icon-guanbi2 {
  353. margin-top: 75rpx !important;
  354. }
  355. &.pageOn {
  356. border-radius: 12rpx;
  357. }
  358. .right {
  359. position: relative;
  360. &::before {
  361. content: "";
  362. position: absolute;
  363. top: 0;
  364. right: 20rpx;
  365. left: 20rpx;
  366. border-top: 1rpx solid #EEEEEE;
  367. }
  368. .item {
  369. flex: 1;
  370. min-width: 0;
  371. padding: 34rpx 0;
  372. margin: 0;
  373. font-size: 26rpx;
  374. line-height: 36rpx;
  375. color: #999999;
  376. .num {
  377. font-family: SemiBold;
  378. font-weight: 500;
  379. font-size: 28rpx;
  380. margin-left: 8rpx;
  381. color: #333333;
  382. }
  383. }
  384. .iconfont {
  385. font-size: 40rpx;
  386. margin-bottom: 8rpx;
  387. }
  388. }
  389. .left {
  390. padding: 32rpx 20rpx;
  391. .pictrue {
  392. width: 90rpx;
  393. height: 90rpx;
  394. border: 1px solid #EEEEEE;
  395. border-radius: 50%;
  396. margin-right: 20rpx;
  397. image {
  398. width: 100%;
  399. height: 100%;
  400. border-radius: 50%;
  401. }
  402. .king{
  403. width: 36rpx;
  404. height: 36rpx;
  405. position: absolute;
  406. top:-18rpx;
  407. right: -8rpx;
  408. }
  409. }
  410. .text {
  411. flex: 1;
  412. font-weight: 400;
  413. //color: #333333;
  414. font-size: 28rpx;
  415. .name {
  416. margin-bottom: 8rpx;
  417. .nameCon {
  418. max-width: 190rpx;
  419. font-weight: bold;
  420. }
  421. .lable {
  422. height: 32rpx;
  423. padding: 0 8rpx;
  424. border-radius: 16rpx;
  425. margin-left: 8rpx;
  426. font-weight: 500;
  427. font-size: 20rpx;
  428. line-height: 32rpx;
  429. .iconfont {
  430. margin-right: 4rpx;
  431. font-size: 20rpx;
  432. }
  433. }
  434. }
  435. .progress {
  436. overflow: hidden;
  437. background-color: #EEEEEE;
  438. width: 120rpx;
  439. height: 14rpx;
  440. border-radius: 7rpx;
  441. position: relative;
  442. margin-right: 8rpx;
  443. .bg-reds {
  444. width: 0;
  445. height: 14rpx;
  446. border-radius: 7rpx;
  447. transition: width 0.6s ease;
  448. background: linear-gradient(90deg, var(--view-theme) 0%, var(--view-gradient) 100%);
  449. }
  450. }
  451. .percent {
  452. font-size: 20rpx;
  453. line-height: 20rpx;
  454. color: #666666;
  455. }
  456. .phone {
  457. font-weight: 400;
  458. //color: #666666;
  459. font-size: 20rpx;
  460. margin-top: 6rpx;
  461. .icon-shouji2 {
  462. margin-right: 4rpx;
  463. font-size: 20rpx;
  464. }
  465. }
  466. }
  467. .right::before {
  468. display: none;
  469. }
  470. .item {
  471. width: 108rpx;
  472. padding: 0;
  473. overflow: hidden;
  474. text-align: center;
  475. font-size: 22rpx;
  476. color: #999999;
  477. .num {
  478. margin: 0 0 12rpx;
  479. font-size: 32rpx;
  480. }
  481. .iconfont {
  482. font-weight: 500;
  483. color: #333333;
  484. font-size: 40rpx;
  485. margin: 0 0 12rpx;
  486. }
  487. }
  488. }
  489. .bottom {
  490. position: relative;
  491. &::before {
  492. content: "";
  493. position: absolute;
  494. top: 0;
  495. right: 20rpx;
  496. left: 20rpx;
  497. border-top: 1px solid #EEEEEE;
  498. }
  499. .item {
  500. flex: 1;
  501. padding: 42rpx 0 40rpx;
  502. text-align: center;
  503. font-weight: 500;
  504. font-size: 22rpx;
  505. line-height: 30rpx;
  506. color: #999999;
  507. }
  508. .num {
  509. margin: 0 0 12rpx;
  510. font-family: SemiBold;
  511. font-weight: 500;
  512. font-size: 32rpx;
  513. line-height: 32rpx;
  514. color: #333333;
  515. }
  516. }
  517. }
  518. </style>