index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <view class="vipGrade">
  3. <view class="headerBg">
  4. <view class="header" v-if="info.user">
  5. <view class="top acea-row row-middle">
  6. <view class="pictrue">
  7. <image :src="info.user.avatar"></image>
  8. </view>
  9. <view class="text">
  10. <view class="name acea-row row-middle">
  11. <view class="nameCon line1">{{info.user.nickname}}</view>
  12. <view v-if="info.level_info.grade" class="num">lv.{{info.level_info.grade}}</view>
  13. </view>
  14. <view class="idNum">ID:{{info.user.uid}}</view>
  15. </view>
  16. </view>
  17. <view class="list acea-row row-around row-middle">
  18. <view class="item">
  19. <view class="num">{{info.user.now_money}}</view>
  20. <view>余额</view>
  21. </view>
  22. <view class="item">
  23. <view class="num">{{info.user.integral}}</view>
  24. <view>积分</view>
  25. </view>
  26. <view class="item">
  27. <view class="num">{{ info.level_info.discount ? parseFloat(info.level_info.discount)/10 : '0'}}</view>
  28. <view>折扣</view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="qrCode">
  34. <view class="header acea-row row-between-wrapper">
  35. <view class="title" :class="{'on': codeIndex == index,'onLeft':codeIndex == 1}"
  36. v-for="(item, index) in codeList" :key="index" @click="tapCode(index)">{{item.name}}</view>
  37. </view>
  38. <view class="acea-row row-center-wrapper" style="margin-top: 35rpx;">
  39. <w-qrcode :options="config.qrc" @generate="hello"></w-qrcode>
  40. </view>
  41. </view>
  42. <view class="store acea-row row-between-wrapper" v-if="storeList.length">
  43. <view class="title">
  44. <text class="iconfont icon-mendian1"></text>
  45. 附近门店
  46. </view>
  47. <view class="acea-row" @click="goMap">
  48. 距 <view class="storeName line1">{{storeList[0].name}}</view> {{storeList[0].range}}km<text class="iconfont icon-gengduo3"></text></view>
  49. </view>
  50. <home v-if="navigation"></home>
  51. </view>
  52. </template>
  53. <script>
  54. // +----------------------------------------------------------------------
  55. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  56. // +----------------------------------------------------------------------
  57. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  58. // +----------------------------------------------------------------------
  59. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  60. // +----------------------------------------------------------------------
  61. // | Author: CRMEB Team <admin@crmeb.com>
  62. // +----------------------------------------------------------------------
  63. import home from '@/components/home/index.vue'
  64. import { getlevelInfo, getRandCode } from '@/api/user.js';
  65. import { storeListApi } from "@/api/store";
  66. export default {
  67. components: {
  68. home
  69. },
  70. data() {
  71. return {
  72. info:{},
  73. codeList: [{
  74. name: '付款码'
  75. }, {
  76. name: '核销码'
  77. }],
  78. codeIndex:0,
  79. config: {
  80. qrc: {
  81. code: '',
  82. size: 380, // 二维码大小
  83. level: 3, //等级 0~4
  84. bgColor: '#FFFFFF', //二维码背景色 默认白色
  85. border: {
  86. color: ['#eee', '#eee'], //边框颜色支持渐变色
  87. lineWidth: 1, //边框宽度
  88. },
  89. color: ['#333', '#333'], //边框颜色支持渐变色
  90. }
  91. },
  92. user_latitude: 0,
  93. user_longitude: 0,
  94. storeList: []
  95. };
  96. },
  97. onLoad() {
  98. this.levelInfo();
  99. this.getCode();
  100. try {
  101. this.user_latitude = uni.getStorageSync('user_latitude');
  102. this.user_longitude = uni.getStorageSync('user_longitude');
  103. } catch (e) {}
  104. },
  105. onReady() {},
  106. onShow() {
  107. uni.removeStorageSync('form_type_cart');
  108. },
  109. mounted() {
  110. if (this.user_latitude && this.user_longitude) {
  111. this.getList();
  112. } else {
  113. this.selfLocation();
  114. }
  115. },
  116. methods: {
  117. goMap(){
  118. uni.navigateTo({
  119. url: '/pages/store/map/index'
  120. })
  121. },
  122. selfLocation() {
  123. let self = this
  124. // #ifdef H5
  125. if (self.$wechat.isWeixin()) {
  126. self.$wechat.location().then(res => {
  127. this.user_latitude = res.latitude;
  128. this.user_longitude = res.longitude;
  129. uni.setStorageSync('user_latitude', res.latitude);
  130. uni.setStorageSync('user_longitude', res.longitude);
  131. self.getList();
  132. })
  133. } else {
  134. // #endif
  135. uni.getLocation({
  136. type: 'wgs84',
  137. success: (res) => {
  138. try {
  139. this.user_latitude = res.latitude;
  140. this.user_longitude = res.longitude;
  141. uni.setStorageSync('user_latitude', res.latitude);
  142. uni.setStorageSync('user_longitude', res.longitude);
  143. } catch {}
  144. self.getList();
  145. },
  146. complete: function() {
  147. self.getList();
  148. }
  149. });
  150. // #ifdef H5
  151. }
  152. // #endif
  153. },
  154. // 获取门店列表数据
  155. getList: function() {
  156. let data = {
  157. latitude: this.user_latitude || "", //纬度
  158. longitude: this.user_longitude || "", //经度
  159. page: 1,
  160. limit: 1
  161. };
  162. storeListApi(data)
  163. .then(res => {
  164. this.storeList = res.data.list.list;
  165. })
  166. .catch(err => {
  167. this.$util.Tips({
  168. title: err
  169. })
  170. });
  171. },
  172. getCode() {
  173. getRandCode().then(res => {
  174. let code = res.data.code;
  175. this.config.qrc.code = code;
  176. }).catch(err => {
  177. return this.$util.Tips(err);
  178. })
  179. },
  180. levelInfo(){
  181. getlevelInfo().then(res=>{
  182. this.info = res.data;
  183. }).catch(err=>{
  184. return this.$util.Tips({
  185. title: err
  186. });
  187. })
  188. },
  189. tapCode(index) {
  190. this.codeIndex = index;
  191. if (index == 0) {
  192. this.getCode();
  193. } else {
  194. let code = this.info.user.bar_code;
  195. this.config.qrc.code = code;
  196. }
  197. },
  198. hello(res) {
  199. },
  200. },
  201. onReachBottom() {
  202. }
  203. }
  204. </script>
  205. <style lang="scss">
  206. page{
  207. background: linear-gradient(121deg, #F5EBE1 0%, #FFDFBE 100%);
  208. }
  209. .vipGrade{
  210. .headerBg{
  211. background: url('../static/big-bg.png') no-repeat;
  212. background-size: 100% 100%;
  213. width: 100%;
  214. height: 476rpx;
  215. padding-top: 1rpx;
  216. .header{
  217. background: url('../static/grade-bg.png') no-repeat;
  218. background-size: 100% 100%;
  219. width: 690rpx;
  220. height: 286rpx;
  221. margin: 26rpx auto;
  222. padding: 28rpx 28rpx 0 28rpx;
  223. .top{
  224. .pictrue{
  225. width: 92rpx;
  226. height: 92rpx;
  227. border: 1px solid #FFFFFF;
  228. margin-right: 20rpx;
  229. border-radius: 50%;
  230. image{
  231. border-radius: 50%;
  232. width:100%;
  233. height: 100%;
  234. }
  235. }
  236. .text{
  237. width: 400rpx;
  238. .name{
  239. .nameCon{
  240. color: #EDCAAC;
  241. font-size: 28rpx;
  242. max-width: 332rpx;
  243. margin-right: 10rpx;
  244. }
  245. .num{
  246. border-radius: 4px;
  247. border: 1px solid #EDCAAC;
  248. background: rgba(215,177,144,0.2);
  249. font-size: 20rpx;
  250. font-weight: 400;
  251. color: #EDCAAC;
  252. padding: 0 4rpx;
  253. }
  254. }
  255. .idNum{
  256. font-weight: 400;
  257. color: #EDCAAC;
  258. font-size: 24rpx;
  259. margin-top: 5rpx;
  260. }
  261. }
  262. }
  263. }
  264. .list{
  265. margin-top: 46rpx;
  266. .item{
  267. color: #EDCAAC;
  268. font-size: 22rpx;
  269. text-align: center;
  270. .num{
  271. font-size: 40rpx;
  272. margin-bottom: 15rpx;
  273. }
  274. }
  275. }
  276. }
  277. .qrCode{
  278. width: 690rpx;
  279. height: 700rpx;
  280. background: #FFFFFF;
  281. border-radius: 18rpx;
  282. margin: -134rpx auto 0 auto;
  283. padding-top: 60rpx;
  284. .header{
  285. width: 330rpx;
  286. height: 60rpx;
  287. border-radius: 30rpx;
  288. background: #EEEEEE;
  289. color: #333333;
  290. font-size: 30rpx;
  291. margin: 0 auto;
  292. .title {
  293. width: 146rpx;
  294. height: 100%;
  295. line-height: 60rpx;
  296. border-radius: 30rpx;
  297. text-align: center;
  298. padding-right: 20rpx;
  299. &.onLeft {
  300. padding-left: 34rpx;
  301. }
  302. &.on {
  303. width: 170rpx;
  304. background-color: #333 !important;
  305. color: #fff;
  306. padding: 0 !important;
  307. }
  308. }
  309. }
  310. }
  311. .store{
  312. width: 690rpx;
  313. height: 100rpx;
  314. background: linear-gradient(90deg, #FFAE49 0%, #FCC887 100%);
  315. border-radius: 18rpx;
  316. margin: 26rpx auto;
  317. padding: 0 30rpx;
  318. color: #fff;
  319. font-weight: 500;
  320. font-size: 28rpx;
  321. .iconfont{
  322. margin-right: 20rpx;
  323. font-size: 38rpx;
  324. }
  325. .icon-gengduo3{
  326. font-size: 24rpx;
  327. margin-left: 5rpx;
  328. margin-right: 0;
  329. margin-top: 6rpx;
  330. }
  331. .storeName{
  332. display: inline-block;
  333. max-width: 284rpx;
  334. vertical-align: middle;
  335. }
  336. }
  337. }
  338. </style>