index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <view>
  3. <!-- #ifdef MP-ALIPAY -->
  4. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="我的盲豆"
  5. leftIconSize="0"></u-navbar>
  6. <!-- #endif -->
  7. <!-- #ifdef MP-WEIXIN -->
  8. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="我的盲豆"></u-navbar>
  9. <!-- #endif -->
  10. <!-- #ifndef MP-WEIXIN || MP-ALIPAY -->
  11. <view v-if="pagesNum > 1">
  12. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="我的盲豆" />
  13. </view>
  14. <view v-else>
  15. <u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" :border="true" title="我的盲豆">
  16. <view class="nav-left flex" slot="left" @click="$toIndex()">
  17. <u-icon name="arrow-left" size="20" color="#333"></u-icon>
  18. </view>
  19. </u-navbar>
  20. </view>
  21. <!-- #endif -->
  22. <view class="bean">
  23. <!-- 盲豆数 -->
  24. <view class="bean-balance flex">
  25. <view class="bean-balance-num">{{ initData.coinNum }}</view>
  26. <view class="bean-balance-title">盲豆余额</view>
  27. <view class="">
  28. <view class="bean-balance-btn flex" @click="toCore">立即兑换</view>
  29. <view class="bean-balance-btn flex" @click="onTransfer">盲豆转赠</view>
  30. </view>
  31. </view>
  32. <!-- 盲豆流水 -->
  33. <view class="bean-list">
  34. <view class="flex bean-list-item" v-for="(item, index) in list" :key="index">
  35. <view class="flex left">
  36. <view class="date">{{ $parseTime(item.createdTime) }}</view>
  37. <view class="title">{{ item.logText.split('|')[1] ? item.logText.split('|')[0] : item.logText }}</view>
  38. <view class="beanNum" v-if="item.logText.split('|')[1]">{{ item.logText.split('|')[1] }}</view>
  39. </view>
  40. <view class="flex right">
  41. <view class="amt">{{ item.logMoney > 0 ? '+' : '' }}{{ item.logMoney }}</view>
  42. <view class="balance">余额:{{ item.money }}</view>
  43. <view class="beanNum" v-if="item.logText.split('|')[1]">-</view>
  44. </view>
  45. </view>
  46. </view>
  47. <u-loadmore :line="true" v-if="list.length>7" :status="status" :loading-text="'努力加载中'" :nomore-text="'已经到底了'" />
  48. <view class="flex empty" v-if="!list.length">
  49. <view class="center">
  50. <image class="center-img" src="https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/nodata_6.png"
  51. mode="scaleToFill"></image>
  52. <view class="center-font">还没有记录</view>
  53. </view>
  54. </view>
  55. </view>
  56. <Transfer :popup-show="popupShow" @close="close" @confirm="confirm" :coin-num="coinNum"
  57. v-if="popupShow" />
  58. </view>
  59. </template>
  60. <script>
  61. import $http from '@/utils/request.js'
  62. import Transfer from './components/transfer.vue'
  63. export default {
  64. components: {
  65. Transfer
  66. },
  67. data() {
  68. return {
  69. status: 'nomore', //上拉刷新状态
  70. initData: {},
  71. pageNum: 1,
  72. total: 0,
  73. list: [],
  74. pagesNum: '',
  75. popupShow: false,
  76. coinNum: 0,
  77. };
  78. },
  79. onShow() {
  80. this.pagesNum = getCurrentPages().length
  81. this.getBean()
  82. this.pageList()
  83. },
  84. methods: {
  85. getBean() {
  86. $http.post('/api/v1/mp/user/mine/init', {}).then(res => {
  87. if (res.code == 0) {
  88. this.initData = res.data
  89. this.coinNum = this.initData.coinNum
  90. }
  91. }).catch(() => {})
  92. },
  93. getList() {
  94. uni.showLoading({
  95. title: '加载中'
  96. });
  97. $http.post(`/api/v1/mp/user/mine/coin/log/list?pageNum=${this.pageNum}&pageSize=50`, {}).then(res => {
  98. uni.hideLoading();
  99. if (res.code == 0) {
  100. res.rows.forEach(item => {
  101. item.type = item.type ? JSON.parse(item.type) : ''
  102. })
  103. this.total = res.total
  104. this.list = this.list.concat(res.rows)
  105. }
  106. }).catch(() => {
  107. uni.hideLoading();
  108. })
  109. },
  110. pageList() {
  111. this.pageNum = 1
  112. this.total = 0
  113. this.list = []
  114. this.getList()
  115. },
  116. //盲票转赠
  117. onTransfer() {
  118. this.popupShow = true
  119. },
  120. close() {
  121. this.popupShow = false
  122. },
  123. confirm() {
  124. //刷新盲豆数量
  125. this.getBean()
  126. //刷新盲豆记录
  127. this.pageList()
  128. },
  129. toCore() {
  130. uni.switchTab({
  131. url: "/pages/core/index"
  132. })
  133. },
  134. },
  135. onReachBottom() {
  136. if (this.total < this.pageNum * 50) return;
  137. this.status = 'loading';
  138. ++this.pageNum
  139. if (this.total < this.pageNum * 50) this.status = 'nomore';
  140. else this.status = 'loading';
  141. this.getList()
  142. },
  143. }
  144. </script>
  145. <style lang="scss" scoped>
  146. .bean {
  147. margin: 34rpx 34rpx;
  148. padding-bottom: 100rpx;
  149. // 盲豆数
  150. &-balance {
  151. height: 264rpx;
  152. flex-direction: column;
  153. justify-content: flex-start;
  154. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/coin_bkg.png) center center no-repeat;
  155. background-size: calc(100vw - 68rpx) 264rpx;
  156. margin-bottom: 34rpx;
  157. &-num {
  158. font-size: 52rpx;
  159. line-height: 52rpx;
  160. font-weight: bold;
  161. color: #FFFFFF;
  162. margin: 36rpx 0 16rpx;
  163. }
  164. &-title {
  165. font-size: 26rpx;
  166. line-height: 26rpx;
  167. margin-bottom: 24rpx;
  168. font-weight: 500;
  169. color: #FFFFFF;
  170. opacity: 0.72;
  171. }
  172. &-btn {
  173. display: inline-block;
  174. margin: 0 20px;
  175. width: 200rpx;
  176. height: 70rpx;
  177. line-height: 70rpx;
  178. font-size: 30rpx;
  179. text-align: center;
  180. background: #fff;
  181. border-radius: 16rpx;
  182. image {
  183. width: 56rpx;
  184. height: 56rpx;
  185. margin-right: 10rpx;
  186. }
  187. }
  188. }
  189. // 盲豆流水
  190. &-list {
  191. background-color: #FFFFFF;
  192. padding: 0 34rpx;
  193. border-radius: 22rpx;
  194. &-item {
  195. justify-content: space-between;
  196. padding: 40rpx 0;
  197. border-bottom: 1px solid #eee;
  198. .left {
  199. flex-direction: column;
  200. justify-content: space-between;
  201. align-items: flex-start;
  202. .date {
  203. color: #AAAAAA;
  204. line-height: 24rpx;
  205. margin-bottom: 28rpx;
  206. }
  207. .title {
  208. font-size: 30rpx;
  209. line-height: 30rpx;
  210. }
  211. .beanNum {
  212. margin-top: 20rpx;
  213. color: #AAAAAA;
  214. }
  215. }
  216. .right {
  217. flex-direction: column;
  218. justify-content: space-between;
  219. align-items: flex-end;
  220. .amt {
  221. color: #FF4208;
  222. font-size: 30rpx;
  223. line-height: 30rpx;
  224. margin-bottom: 28rpx;
  225. }
  226. .balance {
  227. color: #AAAAAA;
  228. }
  229. .beanNum{
  230. margin-top: 20rpx;
  231. color: #fff;
  232. }
  233. }
  234. }
  235. &-item:last-child {
  236. border-bottom: none;
  237. }
  238. }
  239. }
  240. .empty {
  241. height: 60vh;
  242. .center {
  243. text-align: center;
  244. &-img {
  245. width: 228rpx;
  246. height: 320rpx;
  247. }
  248. &-font {
  249. font-size: 30rpx;
  250. font-weight: 400;
  251. color: #999999;
  252. margin-bottom: 250rpx;
  253. }
  254. }
  255. }
  256. </style>