integral.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <template>
  2. <view class="integral">
  3. <!-- 标题栏 -->
  4. <view class="nav">
  5. <image src="http://t9.9026.com/imgs/integralbg.png" style="width: 100%; height: 100%;"></image>
  6. <view class="PointsColumn">
  7. <image src="/static/icon/integralicon.png"></image>
  8. <text>{{userIntegral}}</text>
  9. </view>
  10. <view class="titletext">
  11. <view class="textitem" @click="gointegralRecord">
  12. <image style="width: 38rpx;height: 44rpx;" src="/static/icon/integralrecord.png"></image>
  13. <text>积分记录</text>
  14. </view>
  15. <view class="textitem" @click="goMyorder">
  16. <image src="/static/icon/lament.png"></image>
  17. <text>我的兑换</text>
  18. </view>
  19. <view class="textitem" @click="gointegralRule">
  20. <image style="width: 44rpx;height: 40rpx;" src="/static/icon/integralrule.png"></image>
  21. <text>积分规则</text>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- 占位 -->
  26. <view style="width: 100%; height: 238rpx; "></view>
  27. <!-- 积分商品 -->
  28. <view class="shopList">
  29. <view class="listTop">
  30. <text>积分兑换</text>
  31. </view>
  32. <view class="msg-null" v-if="integralList.length == 0 ">
  33. <image src="https://t9.9026.com/imgs/dataNull.png" style="width: 394rpx;height: 396rpx;" mode=""></image>
  34. <view class="msg-null-text">
  35. <text>暂无数据</text>
  36. </view>
  37. </view>
  38. <view class="ListContent" v-if="integralList.length > 0 ">
  39. <view class="home-hotel-img-content">
  40. <view @click="goIntegralDetail(item.id)" class="home-hotel-img-content-item" v-for="(item,index) in integralList" :key="index"
  41. :style="{marginTop:item.marginTop || 0 }" >
  42. <image class="home-hotel-img-content-item-img"
  43. :class="item.short?'home-hotel-img-content-item-img': 'home-hotel-img-content-item-img-long' "
  44. :src="item.cover_img" mode=""></image>
  45. <view class="text">
  46. <text class="text-top">{{item.name}}</text>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <!-- 触底 -->
  52. <view class="home-bottom" v-if="integralList.length > 0 ">
  53. <uni-load-more :status="status" color="#CCCCCC" :content-text="contentText" />
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. export default{
  60. data(){
  61. return{
  62. // 用户积分
  63. userIntegral:0,
  64. contentText: {
  65. contentdown: '查看更多',
  66. contentrefresh: '加载中',
  67. contentnomore: '—— 已经到底啦 ——'
  68. },
  69. // 积分产品列表
  70. integralList:[],
  71. arr:[],
  72. // 分页
  73. page: 1,
  74. pagesize: 15,
  75. totalElements: '',
  76. allListItem: '',
  77. // 组件uni-load-more
  78. status: 'noMore',
  79. }
  80. },
  81. onLoad() {
  82. this.getProductList()
  83. this.getInfo()
  84. uni.$on('refreshData',()=>{
  85. this.getInfo()
  86. })
  87. },
  88. onUnload() {
  89. uni.$emit('refreshOrderNum')
  90. },
  91. // 触底加载
  92. onReachBottom() {
  93. // 触底的时候请求数据,即为上拉加载更多
  94. var allTotal = this.page * this.pagesize
  95. console.log(allTotal, '----allTotal');
  96. //this.page为加载次数,this.pagesize为每一次加载的数据条数
  97. if (allTotal < this.totalElements) {
  98. //this.totalElements为请求数据的总条数。只要现有条数小于总条数就就执行一下代码
  99. this.allListItem = false;
  100. this.page++;
  101. //加载次数递加
  102. this.status = "loading"
  103. this.$api.product.getProducts({ //请求更多数据列表
  104. page: this.page,
  105. type:2,
  106. }).then(res => {
  107. let ret = [...this.integralList, ...res.data.data]
  108. this.integralList = ret
  109. console.log(ret)
  110. })
  111. } else {
  112. this.allListItem = true;
  113. console.log('已加载全部数据')
  114. this.status = "noMore"
  115. }
  116. },
  117. methods:{
  118. //用户信息
  119. getInfo(){
  120. this.$api.my.userInfo().then(res=>{
  121. this.$store.dispatch('user/info', res.data)
  122. this.userIntegral=this.$store.getters.userInfo.integral
  123. })
  124. },
  125. // 获取积分产品列表
  126. getProductList(){
  127. this.$api.product.getProducts({
  128. page:0,
  129. type:2,
  130. }).then(res=>{
  131. console.log(res,"积分产品")
  132. if(res.code==0){
  133. this.integralList=res.data.data
  134. this.totalElements = res.data.total
  135. this.pagesize = res.data.per_page
  136. this.shortLong()
  137. }
  138. })
  139. },
  140. shortLong() {
  141. this.integralList.forEach((item, index, arr) => {
  142. if (index % 4 === 0) {
  143. item.short = true
  144. }
  145. if (index % 4 === 1) {
  146. item.long = true
  147. }
  148. if (index % 4 === 2) {
  149. item.long = true
  150. item.marginTop = -68 + "rpx"
  151. }
  152. if (index % 4 === 3) {
  153. item.short = true
  154. }
  155. })
  156. },
  157. // 跳转积分规则
  158. gointegralRule(){
  159. uni.navigateTo({
  160. url:'/pages/my/integral/integralRule'
  161. })
  162. },
  163. // 跳转积分记录
  164. gointegralRecord(){
  165. uni.navigateTo({
  166. url:'/pages/my/integral/integralRecord'
  167. })
  168. },
  169. // 跳转积分产品详情
  170. goIntegralDetail(id){
  171. uni.navigateTo({
  172. url:`/pages/goods/goods-detail/index?id=${id}&type=2`
  173. })
  174. },
  175. // 跳转订单记录
  176. goMyorder(){
  177. uni.navigateTo({
  178. url:'/pages/my/myorders/orders'
  179. })
  180. },
  181. }
  182. }
  183. </script>
  184. <style lang="scss" scoped>
  185. $pageColor:#F9F9F9;
  186. $bgColor:#FFFFFF;
  187. // flex布局居中对齐
  188. @mixin flexlayout {
  189. display: flex;
  190. align-items: center;
  191. justify-content: center;
  192. }
  193. .integral{
  194. height: 100%;
  195. background:$bgColor ;
  196. }
  197. .msg-null{
  198. padding-top: 60rpx;
  199. display: flex;
  200. flex-direction: column;
  201. align-items: center;
  202. justify-content: center;
  203. .msg-null-text{
  204. margin-top: 40rpx;
  205. font-size: 28rpx;
  206. color: #333;
  207. }
  208. }
  209. .home-bottom {
  210. background-color: #FFF;
  211. padding-bottom: 84rpx;
  212. }
  213. .nav{
  214. width: 100%;
  215. height: 238rpx;
  216. position: fixed;
  217. z-index: 100;
  218. background-color: #F9F9F9;
  219. .PointsColumn{
  220. position: absolute;
  221. width: 690rpx;
  222. border-radius: 8rpx;
  223. height: 74rpx;
  224. background: #FFFFFF;
  225. border-radius: $bgColor;
  226. left:30rpx;
  227. top:32rpx;
  228. display: flex;
  229. align-items: center;
  230. image{
  231. margin-left: 30rpx;
  232. width: 46rpx;
  233. height: 46rpx;
  234. }
  235. text{
  236. margin-left: 16rpx;
  237. font-size: 48rpx;
  238. font-family: DINAlternate-Bold, DINAlternate;
  239. font-weight: 500;
  240. color: #333333;
  241. }
  242. }
  243. .titletext{
  244. position: absolute;
  245. bottom:30rpx;
  246. left: 30rpx;
  247. width: 690rpx;
  248. height: 74rpx;
  249. display: flex;
  250. align-items: center;
  251. justify-content: space-between;
  252. .textitem{
  253. display: flex;
  254. align-items: center;
  255. image{
  256. width: 44rpx;
  257. height: 44rpx;
  258. }
  259. text{
  260. margin-left: 8rpx;
  261. font-size: 30rpx;
  262. font-family: PingFang-SC-Bold, PingFang-SC;
  263. font-weight: bold;
  264. color: $bgColor;
  265. }
  266. }
  267. }
  268. }
  269. .shopList{
  270. padding-top: 24rpx;
  271. width: 100%;
  272. background: $bgColor;
  273. border-radius: 16rpx 16rpx 0px 0px;
  274. padding: 0 30rpx;
  275. box-sizing: border-box;
  276. padding-top: 32rpx;
  277. .listTop{
  278. @include flexlayout;
  279. margin-bottom: 40rpx;
  280. text{
  281. font-size: 36rpx;
  282. font-family: PingFang-SC-Bold, PingFang-SC;
  283. font-weight: bold;
  284. color: #333333;
  285. }
  286. }
  287. .ListContent{
  288. .home-hotel-img-content {
  289. display: flex;
  290. align-items: flex-start;
  291. justify-content: space-between;
  292. flex-wrap: wrap;
  293. .home-hotel-img-content-item {
  294. width: 332rpx;
  295. background: #FFFFFF;
  296. box-shadow: 0px 4rpx 8rpx 0px rgba(0, 0, 0, 0.04);
  297. border-radius: 12rpx;
  298. margin-bottom: 26rpx;
  299. overflow: hidden;
  300. .home-hotel-img-content-item-img {
  301. width: 332rpx;
  302. height: 332rpx;
  303. object-fit: cover;
  304. object-position: center;
  305. }
  306. .home-hotel-img-content-item-img-long {
  307. width: 332rpx;
  308. height: 400rpx;
  309. object-fit: cover;
  310. object-position: center;
  311. }
  312. .text {
  313. display: flex;
  314. flex-direction: column;
  315. align-items: flex-start;
  316. justify-content: center;
  317. padding: 18rpx 22rpx 32rpx;
  318. .text-top {
  319. font-size: 28rpx;
  320. font-weight: bold;
  321. color: #333;
  322. }
  323. .text-main {
  324. margin-top: 20rpx;
  325. font-size: 24rpx;
  326. color: #999999;
  327. }
  328. }
  329. }
  330. }
  331. }
  332. // display: flex;
  333. // flex-wrap: wrap;
  334. // .contentItemShort{
  335. // width: 332rpx;
  336. // background: $bgColor;
  337. // box-sizing: border-box;
  338. // box-shadow: 0px 4rpx 8rpx 0px rgba(0,0,0,0.04);
  339. // border-radius: 12rpx;
  340. // display: inline-block;
  341. // margin-bottom: 24rpx;
  342. // image{
  343. // width: 332rpx;
  344. // height: 332rpx;
  345. // }
  346. // .itemName{
  347. // margin:0 18rpx 20rpx 22rpx ;
  348. // font-size: 28rpx;
  349. // font-family: PingFang-SC-Bold, PingFang-SC;
  350. // font-weight: bold;
  351. // color: #333333;
  352. // overflow: hidden;
  353. // }
  354. // .itemPrice{
  355. // margin-left: 22rpx;
  356. // font-size: 28rpx;
  357. // font-family: PingFang-SC-Bold, PingFang-SC;
  358. // font-weight: bold;
  359. // color: #FF6200;
  360. // }
  361. // }
  362. // .contentItemLong{
  363. // width: 332rpx;
  364. // background: $bgColor;
  365. // box-sizing: border-box;
  366. // box-shadow: 0px 4rpx 8rpx 0px rgba(0,0,0,0.04);
  367. // border-radius: 12rpx;
  368. // margin-bottom: 24rpx;
  369. // display: inline-block;
  370. // clear: both;
  371. // image{
  372. // width: 332rpx;
  373. // height: 400rpx;
  374. // }
  375. // .itemName{
  376. // margin:0 18rpx 20rpx 22rpx ;
  377. // font-size: 28rpx;
  378. // font-family: PingFang-SC-Bold, PingFang-SC;
  379. // font-weight: bold;
  380. // color: #333333;
  381. // overflow: hidden;
  382. // }
  383. // .itemPrice{
  384. // margin-left: 22rpx;
  385. // font-size: 28rpx;
  386. // font-family: PingFang-SC-Bold, PingFang-SC;
  387. // font-weight: bold;
  388. // color: #FF6200;
  389. // }
  390. // }
  391. // .contentItem:nth-child(odd){
  392. // margin-right: 26rpx;
  393. // }
  394. // }
  395. }
  396. </style>