index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <scroll-view class="scroll-view" scroll-y="true" @scroll="scrollView">
  3. <!-- #ifdef MP -->
  4. <NavBar titleText="会员码" :iconColor="iconColor" :textColor="iconColor" showBack :isScrolling="isScrolling"></NavBar>
  5. <!-- #endif -->
  6. <view class="wrapper">
  7. <view class="wrapper-content">
  8. <view class="header acea-row row-column row-center" :style="[headerStyle]" v-if="userInfo.member_func_status">
  9. <template v-if="userInfo.level_status">
  10. <view class="title" :style="{ color: currentLevel.color }">尊敬的{{nowLevel.name}}会员</view>
  11. <view class="progress-wrap acea-row row-center-wrapper" :style="{
  12. color: colorToRgba(currentLevel.color||'', 0.8)
  13. }">
  14. <view class="">V{{currentLevel.grade}}</view>
  15. <view class="progress">
  16. <view class="inner" :style="{
  17. width: `${nextLevel > 0 ? (nowLevel.exp / nextLevel.exp_num * 100) : 100}%`,
  18. background: colorToRgba(currentLevel.color||'', 0.8)
  19. }"></view>
  20. </view>
  21. <view v-if="nextLevel">V{{nextLevel.grade}}</view>
  22. </view>
  23. <view class="info acea-row row-center-wrapper" :style="{
  24. color: currentLevel.color
  25. }">
  26. <template v-if="nextLevel">
  27. 还需
  28. <text class="number" :style="{color: colorToRgba(currentLevel.color||'', 0.8)}">
  29. {{nextLevel.exp_num >= nowLevel.exp ? $util.$h.Sub(nextLevel.exp_num, nowLevel.exp) : 0}}
  30. </text>
  31. 经验到下一级
  32. </template>
  33. <template v-else>您已经是最高等级</template>
  34. </view>
  35. </template>
  36. <template v-else>
  37. <view class="title" :style="{ color: currentLevel.color }">尊敬的{{userInfo.nickname}}</view>
  38. <navigator url="/pages/annex/vip_grade_active/index" hover-class="none" class="btn" :style="{ color: currentLevel.color }">
  39. 免费激活等级,享更多权益<text class="iconfont icon-ic_rightarrow"></text>
  40. </navigator>
  41. </template>
  42. </view>
  43. <view class="content">
  44. <!-- <view class="acea-row row-center-wrapper">
  45. <w-barcode :options="config.bar"></w-barcode>
  46. </view> -->
  47. <view class="acea-row row-center-wrapper" style="margin-top: 56rpx;">
  48. <!-- #ifdef MP -->
  49. <image :src="qrc" class="qrcode"></image>
  50. <!-- #endif -->
  51. <!-- #ifdef H5 -->
  52. <image v-if="$wechat.isWeixin()" :src="qrc" class="qrcode"></image>
  53. <w-qrcode v-else :options="config.qrc"></w-qrcode>
  54. <!-- #endif -->
  55. <!-- #ifdef APP-PLUS -->
  56. <w-qrcode :options="config.qrc"></w-qrcode>
  57. <!-- #endif -->
  58. </view>
  59. <view class="codeNum acea-row row-center-wrapper">{{config.bar.code}}</view>
  60. <view class="balance-wrapper">
  61. <view class="balance acea-row row-column row-center-wrapper">
  62. <view class="">当前余额<text class="iconfont" :class="[isEye?'icon-ic_Eyes':'icon-ic_eye']" @click="toggleEye"></text></view>
  63. <view class="number" v-if="isEye">{{userInfo.now_money}}</view>
  64. <view class="number" v-else style="font-weight: 500;font-size: 48rpx;">******</view>
  65. </view>
  66. <view class="attribute acea-row row-center-wrapper">
  67. <view class="item" @click="goDetail(1)">
  68. <view class="iconfont icon-ic_coupon"></view>
  69. <view class="">{{userInfo.couponCount}}张券</view>
  70. </view>
  71. <view class="item" @click="goDetail(2)">
  72. <view class="iconfont icon-ic_gold1"></view>
  73. <view class="">{{userInfo.integral}}积分</view>
  74. </view>
  75. <view class="item" @click="goDetail(3)" v-if="userInfo.member_func_status">
  76. <view class="iconfont icon-ic_sale"></view>
  77. <view v-if="userInfo.level_status" class="">{{userInfo.vip_discount}}折</view>
  78. <view v-else class="">暂无折扣</view>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </scroll-view>
  86. </template>
  87. <script>
  88. // #ifdef MP
  89. import NavBar from '@/components/NavBar.vue'
  90. // #endif
  91. import {
  92. getUserInfo,
  93. getlevelInfo,
  94. getRandCode,
  95. } from '@/api/user.js';
  96. import {
  97. activityCodeApi
  98. } from '@/api/activity.js';
  99. export default {
  100. components: {
  101. // #ifdef MP
  102. NavBar,
  103. // #endif
  104. },
  105. data() {
  106. return {
  107. iconColor: '#FFFFFF',
  108. isScrolling: false,
  109. userInfo: {},
  110. VipList: [],
  111. currentLevel: {},
  112. nextLevel: null,
  113. nowLevel: {},
  114. isEye: true,
  115. config: {
  116. bar: {
  117. code: '',
  118. color: ['#000'],
  119. bgColor: '#FFFFFF', // 背景色
  120. width: 480, // 宽度
  121. height: 110 // 高度
  122. },
  123. qrc: {
  124. code: '',
  125. size: 380, // 二维码大小
  126. level: 3, //等级 0~4
  127. bgColor: '#FFFFFF', //二维码背景色 默认白色
  128. border: {
  129. color: ['#eee', '#eee'], //边框颜色支持渐变色
  130. lineWidth: 3, //边框宽度
  131. },
  132. color: ['#333', '#333'], //边框颜色支持渐变色
  133. }
  134. },
  135. qrc: ''
  136. }
  137. },
  138. computed: {
  139. headerStyle() {
  140. let styleObject = {};
  141. if (this.nextLevel) {
  142. styleObject['background'] = `linear-gradient(91deg, ${this.colorToRgba(this.currentLevel.color||'', 0.05)} 0%, ${this.colorToRgba(this.currentLevel.color||'', 0.4)} 100%)`;
  143. }
  144. return styleObject;
  145. }
  146. },
  147. onLoad() {
  148. this.getCode();
  149. this.getUserInfo();
  150. this.activityCodeApi();
  151. },
  152. methods: {
  153. activityCodeApi() {
  154. activityCodeApi(90, 0).then(res => {
  155. const {
  156. routineUrl,
  157. wechatUrl
  158. } = res.data;
  159. // #ifdef MP
  160. this.qrc = routineUrl;
  161. // #endif
  162. // #ifdef H5
  163. if (this.$wechat.isWeixin()) {
  164. this.qrc = wechatUrl;
  165. }
  166. // #endif
  167. });
  168. },
  169. goDetail(val) {
  170. if (val == 1) {
  171. uni.navigateTo({
  172. url: '/pages/users/user_coupon/index'
  173. })
  174. } else if (val == 2) {
  175. uni.navigateTo({
  176. url: '/pages/users/user_integral/index'
  177. })
  178. } else if (val == 3) {
  179. if (this.userInfo.level_status) {
  180. uni.navigateTo({
  181. url: '/pages/users/user_vip/index'
  182. })
  183. } else {
  184. uni.navigateTo({
  185. url: '/pages/annex/vip_grade_active/index'
  186. })
  187. }
  188. }
  189. },
  190. // #ifdef MP
  191. scrollView(e) {
  192. if (e.detail.scrollTop > 50) {
  193. this.isScrolling = true;
  194. this.iconColor = '#333333';
  195. } else if (e.detail.scrollTop < 50) {
  196. this.isScrolling = false;
  197. this.iconColor = '#FFFFFF';
  198. }
  199. },
  200. // #endif
  201. getCode() {
  202. getRandCode().then(res => {
  203. let code = res.data.code;
  204. this.config.bar.code = code;
  205. this.config.qrc.code = code;
  206. }).catch(err => {
  207. return this.$util.Tips(err);
  208. })
  209. },
  210. getUserInfo: function() {
  211. let that = this;
  212. getUserInfo().then(res => {
  213. that.userInfo = res.data
  214. that.config.bar.code = that.userInfo.bar_code;
  215. that.config.qrc.code = that.userInfo.bar_code;
  216. if (that.userInfo.member_func_status) {
  217. this.getlevelInfo();
  218. }
  219. });
  220. },
  221. getlevelInfo: function() {
  222. getlevelInfo().then(res => {
  223. const {
  224. level_info,
  225. level_list,
  226. task,
  227. user
  228. } = res.data;
  229. this.levelInfo = level_info;
  230. level_list.forEach(item => {
  231. switch (item.grade) {
  232. case 1:
  233. item.background = ['#091D2B', '#000F18'];
  234. break;
  235. case 2:
  236. item.background = ['#131A1D', '#040809'];
  237. break;
  238. case 3:
  239. item.background = ['#4B351C', '#14100C'];
  240. break;
  241. case 4:
  242. item.background = ['#1D172B', '#17151E'];
  243. break;
  244. case 5:
  245. item.background = ['#0F0D07', '#0F0D07'];
  246. break;
  247. default:
  248. break;
  249. }
  250. })
  251. this.VipList = level_list;
  252. const index = level_list.findIndex(item => item.grade == level_info.grade);
  253. this.currentLevel = level_list[index];
  254. this.nextLevel = level_list[index + 1];
  255. this.nowLevel = level_info;
  256. });
  257. },
  258. toggleEye() {
  259. this.isEye = !this.isEye;
  260. },
  261. colorToRgba(str, n) {
  262. // 十六进制颜色值的正则表达式
  263. const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
  264. let sColor = str.toLowerCase();
  265. // 十六进制颜色转换为RGB格式
  266. if (sColor && reg.test(sColor)) {
  267. if (sColor.length === 4) {
  268. let sColorNew = '#';
  269. for (let i = 1; i < 4; i += 1) {
  270. sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
  271. }
  272. sColor = sColorNew;
  273. }
  274. // 处理六位颜色值
  275. const sColorChange = [];
  276. for (let k = 1; k < 7; k += 2) {
  277. sColorChange.push(parseInt(`0x${sColor.slice(k, k + 2)}`, 16));
  278. }
  279. return `rgba(${sColorChange.join(',')}, ${n})`;
  280. }
  281. return sColor;
  282. }
  283. },
  284. }
  285. </script>
  286. <style lang="scss" scoped>
  287. .scroll-view {
  288. position: absolute;
  289. top: 0;
  290. right: 0;
  291. bottom: 0;
  292. left: 0;
  293. background: linear-gradient(180deg, #1B1A17 0%, #141414 100%);
  294. .wrapper {
  295. padding: 94rpx 32rpx;
  296. }
  297. .wrapper-content {
  298. border-radius: 32rpx;
  299. background: #FFFFFF;
  300. overflow: hidden;
  301. }
  302. .header {
  303. height: 234rpx;
  304. border-radius: 32rpx 32rpx 0 0;
  305. background: linear-gradient(91deg, rgba(26, 25, 23, 0.9) 0%, #1A1917 100%);
  306. .title {
  307. text-align: center;
  308. font-weight: 600;
  309. font-size: 44rpx;
  310. line-height: 62rpx;
  311. color: #804400;
  312. }
  313. .progress-wrap {
  314. margin-top: 14rpx;
  315. font-size: 22rpx;
  316. line-height: 30rpx;
  317. color: rgba(126, 75, 6, 0.8);
  318. }
  319. .progress {
  320. width: 360rpx;
  321. height: 8rpx;
  322. border-radius: 4rpx;
  323. margin: 0 16rpx;
  324. background: rgba(255, 255, 255, 0.4);
  325. }
  326. .inner {
  327. height: 8rpx;
  328. border-radius: 4rpx;
  329. background: rgba(126, 75, 6, 0.8);
  330. }
  331. .info {
  332. margin-top: 24rpx;
  333. font-size: 24rpx;
  334. line-height: 34rpx;
  335. color: #7E4B06;
  336. }
  337. .number {
  338. margin: 0 4rpx;
  339. font-family: SemiBold;
  340. font-size: 28rpx;
  341. color: rgba(126, 75, 6, 0.8);
  342. }
  343. .btn {
  344. margin-top: 18rpx;
  345. text-align: center;
  346. font-size: 30rpx;
  347. line-height: 42rpx;
  348. .iconfont {
  349. margin-left: 4rpx;
  350. font-size: 32rpx;
  351. }
  352. }
  353. }
  354. .content {
  355. padding: 28rpx 0 0;
  356. }
  357. .codeNum {
  358. margin-top: 12rpx;
  359. letter-spacing: 3px;
  360. font-weight: 500;
  361. font-size: 28rpx;
  362. line-height: 40rpx;
  363. color: #333333;
  364. }
  365. .balance-wrapper {
  366. margin-top: 40rpx;
  367. background: #F9F9F9;
  368. }
  369. .balance {
  370. padding: 54rpx 0 76rpx;
  371. font-size: 24rpx;
  372. line-height: 34rpx;
  373. color: #999999;
  374. .iconfont {
  375. margin-left: 8rpx;
  376. font-size: 28rpx;
  377. }
  378. .number {
  379. margin-top: 20rpx;
  380. font-family: SemiBold;
  381. font-size: 56rpx;
  382. line-height: 56rpx;
  383. color: #333333;
  384. }
  385. }
  386. .attribute {
  387. padding-bottom: 48rpx;
  388. text-align: center;
  389. font-size: 24rpx;
  390. line-height: 34rpx;
  391. color: #666666;
  392. .item {
  393. margin-right: 123rpx;
  394. &:last-child {
  395. margin-right: 0;
  396. }
  397. }
  398. .iconfont {
  399. margin-bottom: 16rpx;
  400. font-size: 48rpx;
  401. color: #444444;
  402. }
  403. }
  404. }
  405. .qrcode {
  406. width: 380rpx;
  407. height: 380rpx;
  408. }
  409. </style>