index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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. import home from '@/components/home/index.vue'
  55. import colors from "@/mixins/color";
  56. import {
  57. getlevelInfo,
  58. getRandCode
  59. } from '@/api/user.js';
  60. import {
  61. storeListApi
  62. } from "@/api/store";
  63. export default {
  64. components: {
  65. home
  66. },
  67. mixins: [colors],
  68. data() {
  69. return {
  70. info:{},
  71. codeList: [{
  72. name: '付款码'
  73. }, {
  74. name: '会员码'
  75. }],
  76. codeIndex:0,
  77. config: {
  78. qrc: {
  79. code: '',
  80. size: 380, // 二维码大小
  81. level: 3, //等级 0~4
  82. bgColor: '#FFFFFF', //二维码背景色 默认白色
  83. border: {
  84. color: ['#eee', '#eee'], //边框颜色支持渐变色
  85. lineWidth: 1, //边框宽度
  86. },
  87. color: ['#333', '#333'], //边框颜色支持渐变色
  88. }
  89. },
  90. user_latitude: 0,
  91. user_longitude: 0,
  92. storeList: []
  93. };
  94. },
  95. onLoad() {
  96. this.levelInfo();
  97. this.getCode();
  98. try {
  99. this.user_latitude = uni.getStorageSync('user_latitude');
  100. this.user_longitude = uni.getStorageSync('user_longitude');
  101. } catch (e) {}
  102. },
  103. onReady() {},
  104. onShow() {
  105. uni.removeStorageSync('form_type_cart');
  106. },
  107. mounted() {
  108. if (this.user_latitude && this.user_longitude) {
  109. this.getList();
  110. } else {
  111. this.selfLocation();
  112. }
  113. },
  114. methods: {
  115. goMap(){
  116. uni.navigateTo({
  117. url: '/pages/store/map/index'
  118. })
  119. },
  120. selfLocation() {
  121. let self = this
  122. // #ifdef H5
  123. if (self.$wechat.isWeixin()) {
  124. self.$wechat.location().then(res => {
  125. this.user_latitude = res.latitude;
  126. this.user_longitude = res.longitude;
  127. uni.setStorageSync('user_latitude', res.latitude);
  128. uni.setStorageSync('user_longitude', res.longitude);
  129. self.getList();
  130. })
  131. } else {
  132. // #endif
  133. uni.getLocation({
  134. type: 'wgs84',
  135. success: (res) => {
  136. try {
  137. this.user_latitude = res.latitude;
  138. this.user_longitude = res.longitude;
  139. uni.setStorageSync('user_latitude', res.latitude);
  140. uni.setStorageSync('user_longitude', res.longitude);
  141. } catch {}
  142. self.getList();
  143. },
  144. complete: function() {
  145. self.getList();
  146. }
  147. });
  148. // #ifdef H5
  149. }
  150. // #endif
  151. },
  152. // 获取门店列表数据
  153. getList: function() {
  154. let data = {
  155. latitude: this.user_latitude || "", //纬度
  156. longitude: this.user_longitude || "", //经度
  157. page: 1,
  158. limit: 1
  159. };
  160. storeListApi(data)
  161. .then(res => {
  162. this.storeList = res.data.list.list;
  163. })
  164. .catch(err => {
  165. this.$util.Tips({
  166. title: err
  167. })
  168. });
  169. },
  170. getCode() {
  171. getRandCode().then(res => {
  172. let code = res.data.code;
  173. this.config.qrc.code = code;
  174. }).catch(err => {
  175. return this.$util.Tips(err);
  176. })
  177. },
  178. levelInfo(){
  179. getlevelInfo().then(res=>{
  180. this.info = res.data;
  181. }).catch(err=>{
  182. return this.$util.Tips({
  183. title: err
  184. });
  185. })
  186. },
  187. tapCode(index) {
  188. this.codeIndex = index;
  189. if (index == 0) {
  190. this.getCode();
  191. } else {
  192. let code = this.info.user.bar_code;
  193. this.config.qrc.code = code;
  194. }
  195. },
  196. hello(res) {
  197. },
  198. },
  199. onReachBottom() {
  200. }
  201. }
  202. </script>
  203. <style lang="scss">
  204. page{
  205. background: linear-gradient(121deg, #F5EBE1 0%, #FFDFBE 100%);
  206. }
  207. .vipGrade{
  208. .headerBg{
  209. background: url('../static/big-bg.png') no-repeat;
  210. background-size: 100% 100%;
  211. width: 100%;
  212. height: 476rpx;
  213. padding-top: 1rpx;
  214. .header{
  215. background: url('../static/grade-bg.png') no-repeat;
  216. background-size: 100% 100%;
  217. width: 690rpx;
  218. height: 286rpx;
  219. margin: 26rpx auto;
  220. padding: 28rpx 28rpx 0 28rpx;
  221. .top{
  222. .pictrue{
  223. width: 92rpx;
  224. height: 92rpx;
  225. border: 1px solid #FFFFFF;
  226. margin-right: 20rpx;
  227. border-radius: 50%;
  228. image{
  229. border-radius: 50%;
  230. width:100%;
  231. height: 100%;
  232. }
  233. }
  234. .text{
  235. width: 400rpx;
  236. .name{
  237. .nameCon{
  238. color: #EDCAAC;
  239. font-size: 28rpx;
  240. max-width: 332rpx;
  241. margin-right: 10rpx;
  242. }
  243. .num{
  244. border-radius: 4px;
  245. border: 1px solid #EDCAAC;
  246. background: rgba(215,177,144,0.2);
  247. font-size: 20rpx;
  248. font-weight: 400;
  249. color: #EDCAAC;
  250. padding: 0 4rpx;
  251. }
  252. }
  253. .idNum{
  254. font-weight: 400;
  255. color: #EDCAAC;
  256. font-size: 24rpx;
  257. margin-top: 5rpx;
  258. }
  259. }
  260. }
  261. }
  262. .list{
  263. margin-top: 46rpx;
  264. .item{
  265. color: #EDCAAC;
  266. font-size: 22rpx;
  267. text-align: center;
  268. .num{
  269. font-size: 40rpx;
  270. margin-bottom: 15rpx;
  271. }
  272. }
  273. }
  274. }
  275. .qrCode{
  276. width: 690rpx;
  277. height: 700rpx;
  278. background: #FFFFFF;
  279. border-radius: 18rpx;
  280. margin: -134rpx auto 0 auto;
  281. padding-top: 60rpx;
  282. .header{
  283. width: 330rpx;
  284. height: 60rpx;
  285. border-radius: 30rpx;
  286. background: #EEEEEE;
  287. color: #333333;
  288. font-size: 30rpx;
  289. margin: 0 auto;
  290. .title {
  291. width: 146rpx;
  292. height: 100%;
  293. line-height: 60rpx;
  294. border-radius: 30rpx;
  295. text-align: center;
  296. padding-right: 20rpx;
  297. &.onLeft {
  298. padding-left: 34rpx;
  299. }
  300. &.on {
  301. width: 170rpx;
  302. background-color: #333 !important;
  303. color: #fff;
  304. padding: 0 !important;
  305. }
  306. }
  307. }
  308. }
  309. .store{
  310. width: 690rpx;
  311. height: 100rpx;
  312. background: linear-gradient(90deg, #FFAE49 0%, #FCC887 100%);
  313. border-radius: 18rpx;
  314. margin: 26rpx auto;
  315. padding: 0 30rpx;
  316. color: #fff;
  317. font-weight: 500;
  318. font-size: 28rpx;
  319. .iconfont{
  320. margin-right: 20rpx;
  321. font-size: 38rpx;
  322. }
  323. .icon-gengduo3{
  324. font-size: 24rpx;
  325. margin-left: 5rpx;
  326. margin-right: 0;
  327. margin-top: 6rpx;
  328. }
  329. .storeName{
  330. display: inline-block;
  331. max-width: 284rpx;
  332. vertical-align: middle;
  333. }
  334. }
  335. }
  336. </style>