integral.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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. // 组件uni-load-more
  65. status: 'noMore',
  66. contentText: {
  67. contentdown: '查看更多',
  68. contentrefresh: '加载中',
  69. contentnomore: '—— 已经到底啦 ——'
  70. },
  71. // 积分产品列表
  72. integralList:[],
  73. arr:[],
  74. }
  75. },
  76. onLoad() {
  77. this.getProductList()
  78. this.getInfo()
  79. uni.$on('refreshData',()=>{
  80. this.getInfo()
  81. })
  82. },
  83. methods:{
  84. //用户信息
  85. getInfo(){
  86. this.$api.my.userInfo().then(res=>{
  87. this.$store.dispatch('user/info', res.data)
  88. this.userIntegral=this.$store.getters.userInfo.integral
  89. })
  90. },
  91. // 获取积分产品列表
  92. getProductList(){
  93. this.$api.product.getProducts({
  94. page:0,
  95. type:2,
  96. }).then(res=>{
  97. console.log(res,"积分产品")
  98. if(res.code==0){
  99. this.integralList=res.data.data
  100. this.shortLong()
  101. }
  102. })
  103. },
  104. shortLong() {
  105. this.integralList.forEach((item, index, arr) => {
  106. if (index % 4 === 0) {
  107. item.short = true
  108. }
  109. if (index % 4 === 1) {
  110. item.long = true
  111. }
  112. if (index % 4 === 2) {
  113. item.long = true
  114. item.marginTop = -68 + "rpx"
  115. }
  116. if (index % 4 === 3) {
  117. item.short = true
  118. }
  119. })
  120. },
  121. // 跳转积分规则
  122. gointegralRule(){
  123. uni.navigateTo({
  124. url:'/pages/my/integral/integralRule'
  125. })
  126. },
  127. // 跳转积分记录
  128. gointegralRecord(){
  129. uni.navigateTo({
  130. url:'/pages/my/integral/integralRecord'
  131. })
  132. },
  133. // 跳转积分产品详情
  134. goIntegralDetail(id){
  135. uni.navigateTo({
  136. url:`/pages/goods/goods-detail/index?id=${id}&type=2`
  137. })
  138. },
  139. // 跳转订单记录
  140. goMyorder(){
  141. uni.navigateTo({
  142. url:'/pages/my/myorders/orders'
  143. })
  144. },
  145. }
  146. }
  147. </script>
  148. <style lang="scss" scoped>
  149. $pageColor:#F9F9F9;
  150. $bgColor:#FFFFFF;
  151. // flex布局居中对齐
  152. @mixin flexlayout {
  153. display: flex;
  154. align-items: center;
  155. justify-content: center;
  156. }
  157. .integral{
  158. height: 100%;
  159. background:$bgColor ;
  160. }
  161. .msg-null{
  162. padding-top: 60rpx;
  163. display: flex;
  164. flex-direction: column;
  165. align-items: center;
  166. justify-content: center;
  167. .msg-null-text{
  168. margin-top: 40rpx;
  169. font-size: 28rpx;
  170. color: #333;
  171. }
  172. }
  173. .home-bottom {
  174. background-color: #FFF;
  175. padding-bottom: 84rpx;
  176. }
  177. .nav{
  178. width: 100%;
  179. height: 238rpx;
  180. position: fixed;
  181. z-index: 100;
  182. background-color: #F9F9F9;
  183. .PointsColumn{
  184. position: absolute;
  185. width: 690rpx;
  186. border-radius: 8rpx;
  187. height: 74rpx;
  188. background: #FFFFFF;
  189. border-radius: $bgColor;
  190. left:30rpx;
  191. top:32rpx;
  192. display: flex;
  193. align-items: center;
  194. image{
  195. margin-left: 30rpx;
  196. width: 46rpx;
  197. height: 46rpx;
  198. }
  199. text{
  200. margin-left: 16rpx;
  201. font-size: 48rpx;
  202. font-family: DINAlternate-Bold, DINAlternate;
  203. font-weight: 500;
  204. color: #333333;
  205. }
  206. }
  207. .titletext{
  208. position: absolute;
  209. bottom:30rpx;
  210. left: 30rpx;
  211. width: 690rpx;
  212. height: 74rpx;
  213. display: flex;
  214. align-items: center;
  215. justify-content: space-between;
  216. .textitem{
  217. display: flex;
  218. align-items: center;
  219. image{
  220. width: 44rpx;
  221. height: 44rpx;
  222. }
  223. text{
  224. margin-left: 8rpx;
  225. font-size: 30rpx;
  226. font-family: PingFang-SC-Bold, PingFang-SC;
  227. font-weight: bold;
  228. color: $bgColor;
  229. }
  230. }
  231. }
  232. }
  233. .shopList{
  234. padding-top: 24rpx;
  235. width: 100%;
  236. background: $bgColor;
  237. border-radius: 16rpx 16rpx 0px 0px;
  238. padding: 0 30rpx;
  239. box-sizing: border-box;
  240. padding-top: 32rpx;
  241. .listTop{
  242. @include flexlayout;
  243. margin-bottom: 40rpx;
  244. text{
  245. font-size: 36rpx;
  246. font-family: PingFang-SC-Bold, PingFang-SC;
  247. font-weight: bold;
  248. color: #333333;
  249. }
  250. }
  251. .ListContent{
  252. .home-hotel-img-content {
  253. display: flex;
  254. align-items: flex-start;
  255. justify-content: space-between;
  256. flex-wrap: wrap;
  257. .home-hotel-img-content-item {
  258. width: 332rpx;
  259. background: #FFFFFF;
  260. box-shadow: 0px 4rpx 8rpx 0px rgba(0, 0, 0, 0.04);
  261. border-radius: 12rpx;
  262. margin-bottom: 26rpx;
  263. overflow: hidden;
  264. .home-hotel-img-content-item-img {
  265. width: 332rpx;
  266. height: 332rpx;
  267. object-fit: cover;
  268. object-position: center;
  269. }
  270. .home-hotel-img-content-item-img-long {
  271. width: 332rpx;
  272. height: 400rpx;
  273. object-fit: cover;
  274. object-position: center;
  275. }
  276. .text {
  277. display: flex;
  278. flex-direction: column;
  279. align-items: flex-start;
  280. justify-content: center;
  281. padding: 18rpx 22rpx 32rpx;
  282. .text-top {
  283. font-size: 28rpx;
  284. font-weight: bold;
  285. color: #333;
  286. }
  287. .text-main {
  288. margin-top: 20rpx;
  289. font-size: 24rpx;
  290. color: #999999;
  291. }
  292. }
  293. }
  294. }
  295. }
  296. // display: flex;
  297. // flex-wrap: wrap;
  298. // .contentItemShort{
  299. // width: 332rpx;
  300. // background: $bgColor;
  301. // box-sizing: border-box;
  302. // box-shadow: 0px 4rpx 8rpx 0px rgba(0,0,0,0.04);
  303. // border-radius: 12rpx;
  304. // display: inline-block;
  305. // margin-bottom: 24rpx;
  306. // image{
  307. // width: 332rpx;
  308. // height: 332rpx;
  309. // }
  310. // .itemName{
  311. // margin:0 18rpx 20rpx 22rpx ;
  312. // font-size: 28rpx;
  313. // font-family: PingFang-SC-Bold, PingFang-SC;
  314. // font-weight: bold;
  315. // color: #333333;
  316. // overflow: hidden;
  317. // }
  318. // .itemPrice{
  319. // margin-left: 22rpx;
  320. // font-size: 28rpx;
  321. // font-family: PingFang-SC-Bold, PingFang-SC;
  322. // font-weight: bold;
  323. // color: #FF6200;
  324. // }
  325. // }
  326. // .contentItemLong{
  327. // width: 332rpx;
  328. // background: $bgColor;
  329. // box-sizing: border-box;
  330. // box-shadow: 0px 4rpx 8rpx 0px rgba(0,0,0,0.04);
  331. // border-radius: 12rpx;
  332. // margin-bottom: 24rpx;
  333. // display: inline-block;
  334. // clear: both;
  335. // image{
  336. // width: 332rpx;
  337. // height: 400rpx;
  338. // }
  339. // .itemName{
  340. // margin:0 18rpx 20rpx 22rpx ;
  341. // font-size: 28rpx;
  342. // font-family: PingFang-SC-Bold, PingFang-SC;
  343. // font-weight: bold;
  344. // color: #333333;
  345. // overflow: hidden;
  346. // }
  347. // .itemPrice{
  348. // margin-left: 22rpx;
  349. // font-size: 28rpx;
  350. // font-family: PingFang-SC-Bold, PingFang-SC;
  351. // font-weight: bold;
  352. // color: #FF6200;
  353. // }
  354. // }
  355. // .contentItem:nth-child(odd){
  356. // margin-right: 26rpx;
  357. // }
  358. // }
  359. }
  360. </style>