shop.vue 7.2 KB

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