integralGoodsList.vue 7.1 KB

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