integral.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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 v-if="item.status==1" @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.filter(item=>{
  134. return item.status == 1
  135. })
  136. this.totalElements = res.data.total
  137. this.pagesize = res.data.per_page
  138. this.shortLong()
  139. }
  140. })
  141. },
  142. shortLong() {
  143. this.integralList.forEach((item, index, arr) => {
  144. if (index % 4 === 0) {
  145. item.short = true
  146. }
  147. if (index % 4 === 1) {
  148. item.long = true
  149. }
  150. if (index % 4 === 2) {
  151. item.long = true
  152. item.marginTop = -68 + "rpx"
  153. }
  154. if (index % 4 === 3) {
  155. item.short = true
  156. }
  157. })
  158. },
  159. // 跳转积分规则
  160. gointegralRule(){
  161. uni.navigateTo({
  162. url:'/pages/my/integral/integralRule'
  163. })
  164. },
  165. // 跳转积分记录
  166. gointegralRecord(){
  167. uni.navigateTo({
  168. url:'/pages/my/integral/integralRecord'
  169. })
  170. },
  171. // 跳转积分产品详情
  172. goIntegralDetail(id){
  173. uni.navigateTo({
  174. url:`/pages/goods/goods-detail/index?id=${id}&type=2`
  175. })
  176. },
  177. // 跳转订单记录
  178. goMyorder(){
  179. uni.navigateTo({
  180. url:'/pages/my/myorders/orders'
  181. })
  182. },
  183. }
  184. }
  185. </script>
  186. <style lang="scss" scoped>
  187. $pageColor:#F9F9F9;
  188. $bgColor:#FFFFFF;
  189. // flex布局居中对齐
  190. @mixin flexlayout {
  191. display: flex;
  192. align-items: center;
  193. justify-content: center;
  194. }
  195. .integral{
  196. height: 100%;
  197. background:$bgColor ;
  198. }
  199. .msg-null{
  200. padding-top: 60rpx;
  201. display: flex;
  202. flex-direction: column;
  203. align-items: center;
  204. justify-content: center;
  205. .msg-null-text{
  206. margin-top: 40rpx;
  207. font-size: 28rpx;
  208. color: #333;
  209. }
  210. }
  211. .home-bottom {
  212. background-color: #FFF;
  213. padding-bottom: 84rpx;
  214. }
  215. .nav{
  216. width: 100%;
  217. height: 238rpx;
  218. position: fixed;
  219. z-index: 100;
  220. background-color: #F9F9F9;
  221. .PointsColumn{
  222. position: absolute;
  223. width: 690rpx;
  224. border-radius: 8rpx;
  225. height: 74rpx;
  226. background: #FFFFFF;
  227. border-radius: $bgColor;
  228. left:30rpx;
  229. top:32rpx;
  230. display: flex;
  231. align-items: center;
  232. image{
  233. margin-left: 30rpx;
  234. width: 46rpx;
  235. height: 46rpx;
  236. }
  237. text{
  238. margin-left: 16rpx;
  239. font-size: 48rpx;
  240. font-family: DINAlternate-Bold, DINAlternate;
  241. font-weight: 500;
  242. color: #333333;
  243. }
  244. }
  245. .titletext{
  246. position: absolute;
  247. bottom:30rpx;
  248. left: 30rpx;
  249. width: 690rpx;
  250. height: 74rpx;
  251. display: flex;
  252. align-items: center;
  253. justify-content: space-between;
  254. .textitem{
  255. display: flex;
  256. align-items: center;
  257. image{
  258. width: 44rpx;
  259. height: 44rpx;
  260. }
  261. text{
  262. margin-left: 8rpx;
  263. font-size: 30rpx;
  264. font-family: PingFang-SC-Bold, PingFang-SC;
  265. font-weight: bold;
  266. color: $bgColor;
  267. }
  268. }
  269. }
  270. }
  271. .shopList{
  272. padding-top: 24rpx;
  273. width: 100%;
  274. background: $bgColor;
  275. border-radius: 16rpx 16rpx 0px 0px;
  276. padding: 0 30rpx;
  277. box-sizing: border-box;
  278. padding-top: 32rpx;
  279. .listTop{
  280. @include flexlayout;
  281. margin-bottom: 40rpx;
  282. text{
  283. font-size: 36rpx;
  284. font-family: PingFang-SC-Bold, PingFang-SC;
  285. font-weight: bold;
  286. color: #333333;
  287. }
  288. }
  289. .ListContent{
  290. .home-hotel-img-content {
  291. display: flex;
  292. align-items: flex-start;
  293. justify-content: space-between;
  294. flex-wrap: wrap;
  295. .home-hotel-img-content-item {
  296. width: 332rpx;
  297. background: #FFFFFF;
  298. box-shadow: 0px 4rpx 8rpx 0px rgba(0, 0, 0, 0.04);
  299. border-radius: 12rpx;
  300. margin-bottom: 26rpx;
  301. overflow: hidden;
  302. .home-hotel-img-content-item-img {
  303. width: 332rpx;
  304. height: 332rpx;
  305. object-fit: cover;
  306. object-position: center;
  307. }
  308. .home-hotel-img-content-item-img-long {
  309. width: 332rpx;
  310. height: 400rpx;
  311. object-fit: cover;
  312. object-position: center;
  313. }
  314. .text {
  315. display: flex;
  316. flex-direction: column;
  317. align-items: flex-start;
  318. justify-content: center;
  319. padding: 18rpx 22rpx 32rpx;
  320. .text-top {
  321. font-size: 28rpx;
  322. font-weight: bold;
  323. color: #333;
  324. }
  325. .text-main {
  326. margin-top: 20rpx;
  327. font-size: 24rpx;
  328. color: #999999;
  329. }
  330. }
  331. }
  332. }
  333. }
  334. // display: flex;
  335. // flex-wrap: wrap;
  336. // .contentItemShort{
  337. // width: 332rpx;
  338. // background: $bgColor;
  339. // box-sizing: border-box;
  340. // box-shadow: 0px 4rpx 8rpx 0px rgba(0,0,0,0.04);
  341. // border-radius: 12rpx;
  342. // display: inline-block;
  343. // margin-bottom: 24rpx;
  344. // image{
  345. // width: 332rpx;
  346. // height: 332rpx;
  347. // }
  348. // .itemName{
  349. // margin:0 18rpx 20rpx 22rpx ;
  350. // font-size: 28rpx;
  351. // font-family: PingFang-SC-Bold, PingFang-SC;
  352. // font-weight: bold;
  353. // color: #333333;
  354. // overflow: hidden;
  355. // }
  356. // .itemPrice{
  357. // margin-left: 22rpx;
  358. // font-size: 28rpx;
  359. // font-family: PingFang-SC-Bold, PingFang-SC;
  360. // font-weight: bold;
  361. // color: #FF6200;
  362. // }
  363. // }
  364. // .contentItemLong{
  365. // width: 332rpx;
  366. // background: $bgColor;
  367. // box-sizing: border-box;
  368. // box-shadow: 0px 4rpx 8rpx 0px rgba(0,0,0,0.04);
  369. // border-radius: 12rpx;
  370. // margin-bottom: 24rpx;
  371. // display: inline-block;
  372. // clear: both;
  373. // image{
  374. // width: 332rpx;
  375. // height: 400rpx;
  376. // }
  377. // .itemName{
  378. // margin:0 18rpx 20rpx 22rpx ;
  379. // font-size: 28rpx;
  380. // font-family: PingFang-SC-Bold, PingFang-SC;
  381. // font-weight: bold;
  382. // color: #333333;
  383. // overflow: hidden;
  384. // }
  385. // .itemPrice{
  386. // margin-left: 22rpx;
  387. // font-size: 28rpx;
  388. // font-family: PingFang-SC-Bold, PingFang-SC;
  389. // font-weight: bold;
  390. // color: #FF6200;
  391. // }
  392. // }
  393. // .contentItem:nth-child(odd){
  394. // margin-right: 26rpx;
  395. // }
  396. // }
  397. }
  398. </style>