耀实惠小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

275 lines
6.0 KiB

  1. <template>
  2. <view>
  3. <view class="title_box">
  4. <image class="bg" :src="img_url+'gold_bg.png'" mode=""></image>
  5. <text class="my_title">我的兑购金</text>
  6. <text class="my_money">{{userInfo.integral}}</text>
  7. </view>
  8. <u-picker mode="time" v-model="show_time" :default-time="default_time" :params="params" @confirm="getTime"></u-picker>
  9. <!-- 数据展示 -->
  10. <view class="item_box">
  11. <view class="item_title" @click="toChangeTime">
  12. <text class="time">{{data_time}}</text>
  13. <u-icon name="arrow-down"></u-icon>
  14. </view>
  15. <view class="item" v-for="(item,index) in list" :key="index">
  16. <view class="left_box">
  17. <image :src="img_url+'gold_icon.png'" mode=""></image>
  18. <view class="text_box">
  19. <text class="title">{{item.name}}</text>
  20. <text class="time">{{item.createTime}}</text>
  21. </view>
  22. </view>
  23. <text class="get_num">{{item.payType==0?'+'+item.money:'-'+item.money}}</text>
  24. </view>
  25. </view>
  26. <view class="empty_box" v-if="list.length==0">
  27. <image :src="img_url+'empty.png'" alt=""></image>
  28. <text class="text_">暂无兑购金记录</text>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import config_img from "@/utils/js/config.js";
  34. export default {
  35. data() {
  36. return {
  37. img_url: config_img.img_url,
  38. data_time: "",
  39. default_time: '',
  40. show_time: false,
  41. params: {
  42. year: true,
  43. month: true,
  44. day: false,
  45. hour: false,
  46. minute: false,
  47. second: false
  48. },
  49. pageNo: 1,
  50. pageSize: 10,
  51. total: null,
  52. isLock: false, //上拉加载锁
  53. list: [],
  54. userInfo: {},
  55. }
  56. },
  57. onLoad() {
  58. // this.userInfo = this.$store.state.userInfo
  59. this.getUserInfo();
  60. this.default_time = new Date().getFullYear()+'-'+ (new Date().getMonth()+1>10? new Date().getMonth()+1: '0'+(new Date().getMonth()+1))
  61. this.data_time = new Date().getFullYear()+'年' +(new Date().getMonth()+1)+'月';
  62. this.getIntegerList({
  63. pageNo: this.pageNo,
  64. pageSize: this.pageSize,
  65. stringDate: this.default_time.replace(/-/,'/')
  66. });
  67. },
  68. async onPullDownRefresh() {
  69. this.pageNo= 1;
  70. this.total = null;
  71. this.isLock = true
  72. this.list = [];
  73. await this.getUserInfo();
  74. await this.getIntegerList({
  75. pageNo: this.pageNo,
  76. pageSize: this.pageSize,
  77. stringDate: this.default_time.replace(/-/,'/')
  78. })
  79. },
  80. //
  81. onReachBottom() {
  82. if(!this.isLock){
  83. if(this.pageNo * this.pageSize > this.total && this.total !== null) {
  84. // 没有更多加载了
  85. this.isLock = true;
  86. this.$Toast('没有更多数据了呢!');
  87. setTimeout(()=> {
  88. // 3秒后解锁
  89. this.isLock = false;
  90. },3000)
  91. return
  92. }
  93. this.pageNo+=1;
  94. console.log(this.default_time)
  95. this.getIntegerList({
  96. pageNo: this.pageNo,
  97. pageSize: this.pageSize,
  98. stringDate: this.default_time.replace(/-/,'/')
  99. })
  100. }
  101. },
  102. methods: {
  103. // 刷新用户信息
  104. getUserInfo () {
  105. return new Promise((resolve, reject) => {
  106. this.$api('getUserInfo').then(res => {
  107. let { code, result, message} = res;
  108. if(code == 200){
  109. let userInfo = {...result.account, ...result.userInfo }
  110. // 更新用户信息缓存
  111. this.userInfo = userInfo
  112. this.$storage.setStorage("__user_info", userInfo)
  113. // this.getAddressInfo();
  114. resolve()
  115. }else {
  116. reject(message)
  117. }
  118. }).catch(err => {
  119. reject(err.message)
  120. })
  121. })
  122. },
  123. toChangeTime() {
  124. this.show_time = true;
  125. },
  126. getIntegerList(params={}) {
  127. uni.showLoading();
  128. this.$api('getInteger',params)
  129. .then(res => {
  130. let { code, result, message } = res
  131. this.isLock = false;
  132. if (code === 200) {
  133. console.log(result)
  134. this.list= this.list.concat(result.records);
  135. uni.stopPullDownRefresh();
  136. uni.hideLoading();
  137. } else {
  138. uni.hideLoading();
  139. uni.stopPullDownRefresh();
  140. this.$Toast(message)
  141. }
  142. this.isLock = true;
  143. uni.stopPullDownRefresh();
  144. })
  145. .catch(err => {
  146. this.isLock = true;
  147. uni.hideLoading();
  148. uni.stopPullDownRefresh();
  149. })
  150. },
  151. getTime(e) {
  152. this.data_time = e.year+"年"+ (e.month>10?e.month:e.month.replace(/0/,'')) +"月";
  153. this.default_time= `${e.year}-${e.month}`;
  154. // 初始化数据
  155. this.list = [];
  156. this.pageNo = 1;
  157. this.total = null;
  158. const params = {
  159. pageNo: this.pageNo,
  160. pageSize: this.pageSize,
  161. stringDate: `${e.year}/${e.month}`
  162. }
  163. console.log(params)
  164. this.getIntegerList(params)
  165. },
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. .title_box {
  171. position: relative;
  172. display: flex;
  173. flex-direction: column;
  174. text-align: center;
  175. margin-bottom: 68rpx;
  176. color: #fff;
  177. .bg {
  178. position: absolute;
  179. height: 239rpx;
  180. z-index: -1;
  181. }
  182. .my_title {
  183. margin-top: 30rpx;
  184. font-size: 36rpx;
  185. }
  186. .my_money {
  187. font-size: 55rpx;
  188. font-weight: bold;
  189. margin-top: 26rpx;
  190. }
  191. }
  192. .empty_box{
  193. width: 100%;
  194. height: 100%;
  195. display: flex;
  196. flex-direction: column;
  197. justify-content: center;
  198. align-items: center;
  199. image{
  200. width: 371rpx;
  201. height: 371rpx;
  202. }
  203. .text_{
  204. margin-top: 10rpx;
  205. font-size: 36rpx;
  206. font-weight: bold;
  207. color: #01AEEA;
  208. }
  209. }
  210. .item_box {
  211. .item_title {
  212. padding-top: 33rpx;
  213. margin-left: 60rpx;
  214. .time {
  215. margin-right: 22rpx;
  216. font-size: 32rpx;
  217. }
  218. }
  219. .item {
  220. width: 670rpx;
  221. margin: 0 auto;
  222. border-bottom: 1rpx solid #E0E0E0;
  223. display: flex;
  224. justify-content: space-between;
  225. align-items: center;
  226. &:last-child {
  227. border-bottom: none;
  228. }
  229. .get_num {
  230. font-size: 30rpx;
  231. color: #DD0F00;
  232. }
  233. .left_box {
  234. display: flex;
  235. align-items: center;
  236. margin-top: 21rpx;
  237. padding-bottom: 20rpx;
  238. image {
  239. width: 58rpx;
  240. height: 58rpx;
  241. margin-right: 30rpx;
  242. }
  243. .text_box {
  244. display: flex;
  245. flex-direction: column;
  246. .title {
  247. font-size: 32rpx;
  248. font-weight: bold;
  249. color: #333333;
  250. }
  251. .time {
  252. font-size: 26rpx;
  253. color: #9A9A9A;
  254. }
  255. }
  256. }
  257. }
  258. }
  259. </style>