userInfor.vue 18 KB

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