integralGoodsList.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <view class="content">
  3. <view class="cont-box">
  4. <view class="top-box">
  5. <view class="my-integral">
  6. <view class="left">
  7. <view class="label">我的芳华币</view>
  8. <view style="margin-top: 30rpx;display: flex;align-items: baseline;">
  9. <view class="integral">{{integral}}</view>
  10. <view class="integralbtn" @click="goIntegral">获取芳华币</view>
  11. </view>
  12. </view>
  13. <view class="btn-box">
  14. <view class="btn" @click="navTo('/pages/user/integral/integralLogsList')">获得记录</view>
  15. <view class="btn" @click="navTo('/pages/user/integral/integralOrderList')">兑换记录</view>
  16. </view>
  17. </view>
  18. <view class="tabs" v-if="tabs.length>0">
  19. <u-tabs
  20. :current="tabIndex"
  21. :scrollable="true"
  22. :list="tabs"
  23. lineColor="#FF5C03"
  24. @change="tabChange">
  25. </u-tabs>
  26. </view>
  27. </view>
  28. <mescroll-body top="288rpx" bottom="0" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  29. <view class="integral-box" >
  30. <view class="item" @click="navTo('/pages/user/integral/integralGoodsDetails?goodsId='+item.goodsId)" v-for="(item,index) in dataList">
  31. <view class="top">
  32. <image :src="item.imgUrl"></image>
  33. </view>
  34. <view class="bottom">
  35. <view class="title ellipsis2">
  36. {{item.goodsName}}
  37. </view>
  38. <view class="price-box">
  39. <view class="price">{{item.integral}}芳华币</view>
  40. <view class="count">价值:{{item.otPrice.toFixed(2)}}元</view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </mescroll-body>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import {getDictByKey} from '@/api/common.js'
  51. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  52. import {getIntegralGoodsList} from '@/api/integral.js'
  53. import {getUserInfo} from '@/api/user'
  54. export default {
  55. mixins: [MescrollMixin],
  56. data() {
  57. return {
  58. integral:0,
  59. type:"0",
  60. typeOptions:[],
  61. tabIndex:0,
  62. tabs: [],
  63. mescroll:null,
  64. downOption: { //下拉刷新
  65. use:true,
  66. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  67. },
  68. upOption: {
  69. onScroll:false,
  70. use: true, // 是否启用上拉加载; 默认true
  71. page: {
  72. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  73. size: 10 // 每页数据的数量,默认10
  74. },
  75. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  76. textNoMore:"已经到底了",
  77. empty: {
  78. icon:'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  79. tip: '暂无数据'
  80. }
  81. },
  82. dataList: []
  83. }
  84. },
  85. onLoad() {
  86. this.getDictByKey("sys_integral_goods_type");
  87. this.getUserInfo();
  88. },
  89. methods: {
  90. getUserInfo(){
  91. getUserInfo().then(
  92. res => {
  93. if(res.code==200){
  94. if(res.user!=null){
  95. this.integral=res.user.integral;
  96. }
  97. }else{
  98. uni.showToast({
  99. icon:'none',
  100. title: "请求失败",
  101. });
  102. }
  103. },
  104. rej => {}
  105. );
  106. },
  107. navTo(url) {
  108. uni.navigateTo({
  109. url: url
  110. })
  111. },
  112. goIntegral() {
  113. let pages = getCurrentPages();
  114. let url = pages[ pages.length - 2];
  115. if(pages.length > 1&&url&&url.route == 'pages/user/integral/points') {
  116. uni.navigateBack()
  117. } else {
  118. uni.navigateTo({
  119. url: '/pages/user/integral/points'
  120. })
  121. }
  122. },
  123. getDictByKey(key){
  124. var data={key:key}
  125. var that=this;
  126. getDictByKey(data).then(
  127. res => {
  128. if(res.code==200){
  129. this.typeOptions=res.data;
  130. this.typeOptions.forEach(function(item,index){
  131. var data={name:item.dictLabel};
  132. that.tabs.push(data);
  133. })
  134. if(this.tabs.length>0){
  135. this.tabIndex=0
  136. }
  137. }
  138. },
  139. err => {
  140. }
  141. );
  142. },
  143. tabChange(item){
  144. console.log(item.index)
  145. this.type=this.typeOptions[item.index].dictValue;
  146. this.mescroll.resetUpScroll()
  147. },
  148. mescrollInit(mescroll) {
  149. this.mescroll = mescroll;
  150. },
  151. /*下拉刷新的回调 */
  152. downCallback(mescroll) {
  153. mescroll.resetUpScroll()
  154. },
  155. upCallback(page) {
  156. //联网加载数据
  157. var that = this;
  158. var data = {
  159. pageNum: page.num,
  160. pageSize: page.size
  161. };
  162. if(this.type!=null){
  163. data.goodsType=this.type
  164. }
  165. getIntegralGoodsList(data).then(res => {
  166. if(res.code==200){
  167. //设置列表数据
  168. if (page.num == 1) {
  169. that.dataList = res.data.list;
  170. } else {
  171. that.dataList = that.dataList.concat(res.data.list);
  172. }
  173. that.mescroll.endBySize(res.data.list.length, res.data.total);
  174. }else{
  175. uni.showToast({
  176. icon:'none',
  177. title: "请求失败",
  178. });
  179. that.dataList = null;
  180. that.mescroll.endErr();
  181. }
  182. });
  183. }
  184. }
  185. }
  186. </script>
  187. <style scoped lang="scss">
  188. page{
  189. height: 100%;
  190. background-color: #f5f5f5;
  191. }
  192. .content{
  193. height: 100%;
  194. .cont-box{
  195. .top-box{
  196. z-index: 999;
  197. padding: 30rpx;
  198. width: 100%;
  199. position: absolute;
  200. top: 0rpx;
  201. left: 0rpx;
  202. .my-integral{
  203. height: 200rpx;
  204. box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  205. background: linear-gradient(#FF5C03, #E2C99E);
  206. border-radius: 30rpx;
  207. display: flex;
  208. align-items: flex-start;
  209. justify-content: space-between;
  210. padding: 30rpx;
  211. .integralbtn {
  212. font-size: 24rpx;
  213. font-family: PingFang SC;
  214. color: #fff;
  215. margin-left: 16rpx;
  216. text-decoration: underline;
  217. }
  218. .btn{
  219. margin-bottom: 30rpx;
  220. background-color: #fff;
  221. border-radius: 30rpx;
  222. display: flex;
  223. align-items: center;
  224. justify-content: center;
  225. padding: 10rpx 15rpx;
  226. font-size: 20upx;
  227. font-family: PingFang SC;
  228. color: #FF5C03;
  229. }
  230. .left{
  231. .label{
  232. font-size: 28upx;
  233. font-family: PingFang SC;
  234. color: #fff;
  235. }
  236. .integral{
  237. font-weight: bold;
  238. font-size: 40upx;
  239. font-family: PingFang SC;
  240. color: #fff;
  241. }
  242. }
  243. .btn-box{
  244. display: flex;
  245. flex-direction: column;
  246. align-items: flex-start;
  247. justify-content: flex-start;
  248. }
  249. }
  250. .tabs{
  251. height: 88rpx;
  252. }
  253. }
  254. .integral-box{
  255. padding: 30rpx;
  256. display: flex;
  257. align-items: flex-start;
  258. justify-content: flex-start;
  259. flex-wrap: wrap;
  260. .item{
  261. box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  262. background-color: #fff;
  263. width: calc(50% - 20rpx);
  264. border-radius: 15rpx;
  265. margin: 10rpx;
  266. display: flex;
  267. flex-direction: column;
  268. align-items: flex-start;
  269. justify-content: flex-start;
  270. &:last-child{
  271. }
  272. .top{
  273. width:100%;
  274. height:300rpx;
  275. image{
  276. border-radius: 15rpx 15rpx 0rpx 0rpx;
  277. width:100%;
  278. height:300rpx;
  279. }
  280. }
  281. .bottom{
  282. width: 100%;
  283. padding: 15rpx;
  284. .title{
  285. font-weight: bold;
  286. font-size: 28upx;
  287. font-family: PingFang SC;
  288. color: #111111;
  289. }
  290. .price-box{
  291. margin-top: 10rpx;
  292. display: flex;
  293. align-items: center;
  294. justify-content: space-between;
  295. width: 100%;
  296. .price{
  297. padding: 5rpx 10rpx;
  298. background-color: #FF5C03;
  299. border-radius: 30rpx;
  300. font-size: 20upx;
  301. font-family: PingFang SC;
  302. color: #ffffff;
  303. }
  304. .count{
  305. font-size: 24upx;
  306. font-family: PingFang SC;
  307. color: #333333;
  308. }
  309. }
  310. }
  311. }
  312. }
  313. }
  314. }
  315. </style>