integralGoodsList.vue 7.5 KB

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