userInfor.vue 14 KB

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