shop.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <view :style="vuex_skin">
  3. <u-navbar title-color="#fff" z-index="90" :border-bottom="false" :is-back="false" title="积分商城"
  4. :background="{'backgroundColor': vuex_theme.shopBg}"></u-navbar>
  5. <mescroll-body-diy ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback"
  6. @up="upCallback">
  7. <view class="bg-card">
  8. <view class="info" style="display: flex;justify-content: space-between;">
  9. <view class="flex" v-if="vuex_userId">
  10. <image style="width: 90rpx;height: 90rpx;border-radius: 50%;" :src="userData.avatar">
  11. </image>
  12. <view class="center data">
  13. <text style="color: #FFD7D9;">我的积分:</text>
  14. <text class="text-bold text-xxl">{{userData.pufaPoint}}</text>
  15. </view>
  16. </view>
  17. <view class="flex" v-else @click="showLogin">
  18. <image style="width: 90rpx;height: 90rpx;border-radius: 50%;" src="/static/icon/unlogin.png">
  19. </image>
  20. <view class="center data">
  21. <text style="color: #FFFFFF;font-weight: 800;">点击授权登录</text>
  22. </view>
  23. </view>
  24. <view class="center" style="margin-right: -30rpx;">
  25. <view class="cu-btn round sm rule">
  26. 积分规则
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="swiper">
  32. <u-swiper :list="swiperList" border-radius="12" height="250"></u-swiper>
  33. </view>
  34. <view class="recommend-info">
  35. <view class="goods-list">
  36. <view class="list" v-for="(item,index) in list" :key="index">
  37. <view class="pictrue">
  38. <image :src="item.imgUrl"></image>
  39. </view>
  40. <view class="title-tag" style="text-align: center;font-weight: 800;">
  41. <text class="text-cut-1">{{item.name}}</text>
  42. </view>
  43. <view class="price-info">
  44. <view class="user-price">
  45. <text class="min">¥</text>
  46. <text class="max">{{item.point}}积分</text>
  47. </view>
  48. </view>
  49. <view class="bottom padding-top-20" @click="$u.toast('暂未开放')">
  50. <button class="cu-btn round text-white bg-base"
  51. style="width: 140upx;height: 50upx;">兑换</button>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </mescroll-body-diy>
  57. <login ref="login" @signIn="signIn" @phoneSuccess="phoneSuccess"></login>
  58. </view>
  59. </template>
  60. <script>
  61. import MescrollBodyDiy from "@/uni_modules/mescroll-uni/components/mescroll-diy/xinlang/mescroll-body.vue";
  62. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  63. export default {
  64. mixins: [MescrollMixin],
  65. components: {
  66. MescrollBodyDiy,
  67. },
  68. data() {
  69. return {
  70. swiperList: [
  71. 'https://gx.vote.activity.obs.cn-south-1.myhuaweicloud.com:443/3b23192e2b684e1e8d606790216d9d19-bff40cda56a61fb3151002945d87ad7.jpg'
  72. ],
  73. downOption: {
  74. auto: false
  75. },
  76. userData: {},
  77. list: []
  78. }
  79. },
  80. onShow() {
  81. this.fetchUserInfo()
  82. },
  83. methods: {
  84. fetchUserInfo(){
  85. if (!this.vuex_userId) {
  86. return
  87. }
  88. let params = {
  89. id: this.vuex_userId
  90. }
  91. this.$api.loginUser.detail(params).then(res => {
  92. if (this.$isNotEmpty(res.data.data)) {
  93. this.userData=res.data.data
  94. let userInfo=this.userData
  95. userInfo.sessionKey=this.$cache.get('userInfo').sessionKey
  96. this.$cache.put('userInfo',userInfo)
  97. this.$u.vuex('vuex_phone',this.userData.phone)
  98. }
  99. })
  100. },
  101. downCallback() {
  102. setTimeout(() => {
  103. this.mescroll.resetUpScroll();
  104. }, 1000)
  105. },
  106. upCallback(mescroll) {
  107. try {
  108. let params = {
  109. current: mescroll.num,
  110. size: mescroll.size,
  111. }
  112. this.$api.pointgoods.list(params).then(res => {
  113. let data = res.data.data.records
  114. let total = res.data.data.total
  115. mescroll.endBySize(data.length, total);
  116. if (mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
  117. this.list = this.list.concat(data); //追加新数据
  118. })
  119. } catch (e) {
  120. console.error(e);
  121. this.mescroll.endErr()
  122. }
  123. }
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. .rule {
  129. background-color: var(--shopRule);
  130. color: #FFFFFF;
  131. padding: 20rpx 40rpx 20rpx 30rpx;
  132. }
  133. .bg-card {
  134. // position: relative;
  135. width: 100vw;
  136. height: 260rpx;
  137. background-color: var(--shopBg);
  138. border-radius: 0 0 10% 10%;
  139. .info {
  140. display: flex;
  141. padding: 30rpx 0rpx 0rpx 40rpx;
  142. .data {
  143. color: #FFFFFF;
  144. margin-left: 10rpx;
  145. }
  146. }
  147. }
  148. .swiper {
  149. margin-top: -120rpx;
  150. padding: 0 20rpx;
  151. }
  152. /* 为你推荐 */
  153. .recommend-info {
  154. padding-top: 30rpx;
  155. width: 100%;
  156. border-radius: 20rpx;
  157. .recommend-title {
  158. display: flex;
  159. align-items: center;
  160. justify-content: center;
  161. width: 100%;
  162. height: 100rpx;
  163. .title {
  164. display: flex;
  165. align-items: center;
  166. image {
  167. width: 416rpx;
  168. height: 40rpx;
  169. }
  170. }
  171. }
  172. .goods-list {
  173. display: flex;
  174. flex-wrap: wrap;
  175. justify-content: space-between;
  176. padding: 0 20rpx;
  177. .list {
  178. width: 49%;
  179. height: 550rpx;
  180. margin-bottom: 20rpx;
  181. background-color: #FFFFFF;
  182. border-radius: 12rpx;
  183. overflow: hidden;
  184. .pictrue {
  185. display: flex;
  186. justify-content: center;
  187. width: 100%;
  188. image {
  189. width: 100%;
  190. height: 340rpx;
  191. }
  192. }
  193. .title-tag {
  194. // display: flex;
  195. height: 70rpx;
  196. padding: 20rpx;
  197. }
  198. .price-info {
  199. display: flex;
  200. flex-wrap: wrap;
  201. align-items: center;
  202. justify-content: center;
  203. padding: 0 20rpx;
  204. height: 50rpx;
  205. .user-price {
  206. display: flex;
  207. justify-content: center;
  208. align-items: center;
  209. text {
  210. color: #e72226;
  211. }
  212. .min {
  213. font-size: 24rpx;
  214. }
  215. .max {
  216. font-size: 32rpx;
  217. }
  218. }
  219. .vip-price {
  220. padding-left: 20rpx;
  221. display: flex;
  222. align-items: center;
  223. image {
  224. width: 26rpx;
  225. height: 26rpx;
  226. margin-right: 10rpx;
  227. }
  228. text {
  229. text-decoration: line-through;
  230. color: #8c8c8c;
  231. font-size: 24rpx;
  232. }
  233. }
  234. }
  235. .bottom {
  236. margin: 10rpx 0;
  237. display: flex;
  238. justify-content: center;
  239. align-items: flex-end;
  240. }
  241. }
  242. }
  243. }
  244. </style>
  245. <!-- <template>
  246. <view :style="vuex_skin">
  247. <mescroll-body-diy ref="mescrollRef" @init="mescrollInit" :down="downOption" :up="upOption" @down="downCallback"
  248. @up="upCallback">
  249. </mescroll-body-diy>
  250. </view>
  251. </template>
  252. <script>
  253. import MescrollBodyDiy from "@/uni_modules/mescroll-uni/components/mescroll-diy/xinlang/mescroll-body.vue";
  254. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  255. export default {
  256. mixins: [MescrollMixin],
  257. data() {
  258. return {
  259. downOption: {
  260. auto: false
  261. },
  262. list: [],
  263. }
  264. },
  265. methods: {
  266. downCallback() {
  267. setTimeout(() => {
  268. this.mescroll.resetUpScroll();
  269. }, 1000)
  270. },
  271. upCallback(mescroll) {
  272. try {
  273. let params = {
  274. current: mescroll.num,
  275. size: mescroll.size,
  276. }
  277. this.$api.pointgoods.list(params).then(res => {
  278. let data = res.data.data.records
  279. let total = res.data.data.total
  280. mescroll.endBySize(data.length, total);
  281. if (mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
  282. this.list = this.list.concat(data); //追加新数据
  283. })
  284. } catch (e) {
  285. console.error(e);
  286. this.mescroll.endErr()
  287. }
  288. }
  289. }
  290. }
  291. </script>
  292. -->