scoreAccumulate.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <template>
  2. <view class="content">
  3. <!-- <view class="navbar">
  4. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  5. </view> -->
  6. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
  7. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  8. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  9. <!-- 空白页 -->
  10. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  11. <!-- 订单列表 -->
  12. <view v-for="(item, index) in tabItem.orderList" :key="index" class="order-item flex">
  13. <view class="title-box">
  14. <view class="title">
  15. <text>{{ item.mark }}</text>
  16. </view>
  17. <view class="time">
  18. <text>{{ item.add_time }}</text>
  19. </view>
  20. </view>
  21. <view class="money">
  22. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  23. </view>
  24. </view>
  25. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  26. </scroll-view>
  27. </swiper-item>
  28. </swiper>
  29. <view class="bottom-box">
  30. <button class="add-btn up" @click="confirmShow">积分转佣金</button>
  31. <navigator url="./setintegral">
  32. <button class="add-btn yue" >积分转账</button>
  33. </navigator>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import { integrallist } from '@/api/functionalUnit.js';
  39. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  40. import empty from '@/components/empty';
  41. import {
  42. getUserInfo
  43. } from '@/api/user.js';
  44. import {
  45. mapState,
  46. mapMutations
  47. } from 'vuex';
  48. import { setMoney } from '@/api/new.js';
  49. export default {
  50. components: {
  51. empty,
  52. uniLoadMore
  53. },
  54. computed: {
  55. ...mapState('user', ['userInfo'])
  56. },
  57. data() {
  58. return {
  59. tabCurrentIndex: 0,
  60. navList: [
  61. {
  62. state: 0,
  63. text: '全部',
  64. loadingType: 'more',
  65. orderList: [],
  66. page: 1, //当前页数
  67. limit: 10 //每次信息条数
  68. },
  69. ],
  70. };
  71. },
  72. onShow() {
  73. // 载入积分数据
  74. this.loadData();
  75. this.loadBaseData();
  76. },
  77. methods: {
  78. ...mapMutations('user', ['setUserInfo']),
  79. // 重新获取用户数据
  80. loadBaseData() {
  81. getUserInfo({})
  82. .then(({
  83. data
  84. }) => {
  85. console.log(data.nickname)
  86. this.setUserInfo(data);
  87. })
  88. .catch(e => {
  89. console.log(e);
  90. });
  91. },
  92. confirmShow(){
  93. uni.showModal({
  94. title: '积分转佣金',
  95. editable: true,
  96. placeholderText:'请输入要转换的积分',
  97. success: res => {
  98. if(res.confirm){
  99. setMoney({
  100. brokerage:+res.content/10
  101. }).then((e)=>{
  102. uni.showToast({
  103. title: '积分转佣金完成'
  104. });
  105. }).catch((err)=>{
  106. console.log(err);
  107. })
  108. }
  109. },
  110. fail: () => {},
  111. complete: () => {}
  112. });
  113. },
  114. // 页面跳转
  115. navto(e) {
  116. uni.navigateTo({
  117. url: e
  118. });
  119. },
  120. //获取收入支出信息
  121. async loadData(source) {
  122. //这里是将订单挂载到tab列表下
  123. let index = this.tabCurrentIndex;
  124. let navItem = this.navList[index];
  125. let state = navItem.state;
  126. if (source === 'tabChange' && navItem.loaded === true) {
  127. //tab切换只有第一次需要加载数据
  128. return;
  129. }
  130. if (navItem.loadingType === 'loading') {
  131. //防止重复加载
  132. return;
  133. }
  134. // 修改当前对象状态为加载中
  135. navItem.loadingType = 'loading';
  136. integrallist(
  137. {
  138. page: navItem.page,
  139. limit: navItem.limit
  140. },
  141. state
  142. )
  143. .then(({ data }) => {
  144. if (data.length > 0) {
  145. navItem.orderList = navItem.orderList.concat(data);
  146. navItem.page++;
  147. }
  148. if (navItem.limit == data.length) {
  149. //判断是否还有数据, 有改为 more, 没有改为noMore
  150. navItem.loadingType = 'more';
  151. return;
  152. } else {
  153. //判断是否还有数据, 有改为 more, 没有改为noMore
  154. navItem.loadingType = 'noMore';
  155. }
  156. uni.hideLoading();
  157. this.$set(navItem, 'loaded', true);
  158. })
  159. .catch(e => {
  160. console.log(e);
  161. });
  162. },
  163. //swiper 切换
  164. changeTab(e) {
  165. this.tabCurrentIndex = e.target.current;
  166. this.loadData('tabChange');
  167. },
  168. //顶部tab点击
  169. tabClick(index) {
  170. this.tabCurrentIndex = index;
  171. }
  172. }
  173. };
  174. </script>
  175. <style lang="scss">
  176. page {
  177. background: #ffffff;
  178. height: 100%;
  179. }
  180. .navbar {
  181. display: flex;
  182. height: 40px;
  183. padding: 0 5px;
  184. background: #fff;
  185. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  186. position: relative;
  187. z-index: 10;
  188. .nav-item {
  189. flex: 1;
  190. display: flex;
  191. justify-content: center;
  192. align-items: center;
  193. height: 100%;
  194. font-size: 15px;
  195. color: $font-color-dark;
  196. position: relative;
  197. &.current {
  198. color: $base-color;
  199. &:after {
  200. content: '';
  201. position: absolute;
  202. left: 50%;
  203. bottom: 0;
  204. transform: translateX(-50%);
  205. width: 44px;
  206. height: 0;
  207. border-bottom: 2px solid $base-color;
  208. }
  209. }
  210. }
  211. }
  212. // 列表
  213. .swiper-box {
  214. height: calc(100% - 44px);
  215. padding-top: 10rpx;
  216. .order-item {
  217. padding: 20rpx 30rpx;
  218. line-height: 1.5;
  219. .title-box {
  220. .title {
  221. font-size: $font-lg;
  222. color: $font-color-base;
  223. }
  224. .time {
  225. font-size: $font-base;
  226. color: $font-color-light;
  227. }
  228. }
  229. .money {
  230. color: #fd5b23;
  231. font-size: $font-lg;
  232. }
  233. }
  234. }
  235. .list-scroll-content {
  236. height: 100%;
  237. }
  238. .content {
  239. height: 100%;
  240. .empty-content {
  241. background-color: #ffffff;
  242. }
  243. }
  244. .bottom-box{
  245. position: absolute;
  246. bottom: 0;
  247. left:0;
  248. right:0;
  249. padding-bottom: 30rpx;
  250. }
  251. .add-btn {
  252. color:#FFF;
  253. &.yue{
  254. background-color: #FFF;
  255. color: #6B4216;
  256. }
  257. &.up {
  258. background: linear-gradient(-90deg, #FAC545, #FFE000);
  259. }
  260. display: flex;
  261. align-items: center;
  262. justify-content: center;
  263. width: 604rpx;
  264. height: 90rpx;
  265. margin: 0 auto;
  266. margin-top: 30rpx;
  267. font-size: $font-lg;
  268. border-radius: 10rpx;
  269. }
  270. .popup-box {
  271. width: 522rpx;
  272. height: 605rpx;
  273. background-color: #ffffff;
  274. border-radius: 20rpx;
  275. position: relative;
  276. .title{
  277. text-align: center;
  278. }
  279. .mian {
  280. display: flex;
  281. flex-direction: column;
  282. align-items: center;
  283. // padding: 32rpx 32rpx;
  284. background-color: #ffffff;
  285. border-radius: 0 0 20rpx 20rpx;
  286. text-align: center;
  287. .delivery {
  288. font-size: 40rpx;
  289. color: #333333;
  290. display: flex;
  291. align-items: center;
  292. flex-direction: column;
  293. image {
  294. margin-top: 48rpx;
  295. width: 172rpx;
  296. height: 160rpx;
  297. }
  298. }
  299. .nocancel {
  300. font-size: 32rpx;
  301. color: #333333;
  302. margin-top: 14rpx;
  303. }
  304. .comfirm-box {
  305. margin-top: 52rpx;
  306. display: flex;
  307. // margin-bottom: 32rpx;
  308. // justify-content: space-around;
  309. .cancel {
  310. display: flex;
  311. align-items: center;
  312. justify-content: center;
  313. width: 197rpx;
  314. height: 74rpx;
  315. border: 1px solid #dcc786;
  316. border-radius: 38rpx;
  317. font-size: 32rpx;
  318. color: #605128;
  319. }
  320. .comfirm {
  321. margin-left: 32rpx;
  322. display: flex;
  323. align-items: center;
  324. justify-content: center;
  325. width: 197rpx;
  326. height: 74rpx;
  327. background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
  328. border-radius: 38px;
  329. font-size: 32rpx;
  330. color: #605128;
  331. }
  332. }
  333. }
  334. }
  335. </style>