index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view class="content">
  3. <!-- 用户信息 -->
  4. <userBar :isLogin="hasLogin" :userInfo="userInfo" @toUser="toUser"></userBar>
  5. <!-- 套餐记录 -->
  6. <view class="list-box">
  7. <swiper-item class="swiper-item">
  8. <scroll-view scroll-y class="scroll-box" @scrolltolower="onreachBottom">
  9. <view class="flex align_center justify_between item-box" v-if="hasLogin" v-for="item in list" :key="item.id" @click="toDetail(item)">
  10. <view class="l_box">{{item.bundleName}}</view>
  11. <view class="flex align_center r_box">
  12. <view>
  13. <view>{{item.createDate.split(' ')[0]}}</view>
  14. <view>{{item.store.name}}</view>
  15. </view>
  16. <view>
  17. <u-icon name="arrow-right"></u-icon>
  18. </view>
  19. </view>
  20. </view>
  21. <view style="padding: 20upx;" v-if="hasLogin">
  22. <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="list.length==0 && status!='loading'" mode="list"></u-empty>
  23. <u-loadmore v-if="list.length||status=='loading'" :status="status" />
  24. </view>
  25. <view v-if="!hasLogin" class="des">请登录后查看套餐记录</view>
  26. </scroll-view>
  27. </swiper-item>
  28. </swiper>
  29. </view>
  30. <uni-popup ref="openModal" type="center">
  31. <uni-popup-dialog content="确定退出登录吗?" @confirm="onOk" title="提示"></uni-popup-dialog>
  32. </uni-popup>
  33. </view>
  34. </template>
  35. <script>
  36. import {
  37. mapState,
  38. mapMutations,
  39. } from 'vuex'
  40. import uniPopup from '@/components/uni-popup/uni-popup.vue'
  41. import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
  42. import { listLookUp, getLookUpDatas } from '@/api/data.js';
  43. import { getCustomerBundle } from '@/api/bundel.js'
  44. import userBar from './userBar.vue'
  45. export default {
  46. components: {
  47. uniPopup,uniPopupDialog,userBar
  48. },
  49. data() {
  50. return {
  51. status: '',
  52. noDataText: '暂无数据',
  53. pageNo: 1,
  54. pageSize: 15,
  55. list: [],
  56. total: 0,
  57. }
  58. },
  59. computed: {
  60. ...mapState(['hasLogin']),
  61. userInfo(){
  62. return this.$store.state.vuex_userInfo
  63. }
  64. },
  65. onReady() {
  66. // 检测是否登录
  67. this.$store.dispatch('checkLogin',()=>{
  68. this.pageInit()
  69. })
  70. },
  71. onLoad() {
  72. // 获取数据字典
  73. // this.getListLookUp();
  74. // 获取支付,收款方式
  75. // this.getLookUpList('PAY_PROCUCT_TYPE', 'vuex_paymentTypeList');
  76. // 刷新首页数据
  77. uni.$on("refashHome",()=>{
  78. this.pageInit()
  79. })
  80. },
  81. onUnload() {
  82. uni.$off('refashHome')
  83. },
  84. // 下拉刷新
  85. onPullDownRefresh(){
  86. this.pageInit()
  87. setTimeout(function () {
  88. uni.stopPullDownRefresh();
  89. }, 1000);
  90. },
  91. onShareAppMessage() {},
  92. methods: {
  93. pageInit(){
  94. if(this.hasLogin){
  95. // 获取扫描记录
  96. this.getbundle(1)
  97. }
  98. },
  99. // 获取数据字典
  100. getListLookUp() {
  101. const _this = this;
  102. listLookUp({ pageNo: 1, pageSize: 1000 }).then(res => {
  103. if (res.status == 200) {
  104. _this.$store.state.vuex_allLookUp = res.data;
  105. }
  106. });
  107. },
  108. // 或某一项字典列表,参数code
  109. getLookUpList(code, vuexKey) {
  110. getLookUpDatas({ type: code }).then(res => {
  111. if (res.status == 200) {
  112. this.$store.state[vuexKey] = res.data || [];
  113. }
  114. });
  115. },
  116. // scroll-view到底部加载更多
  117. onreachBottom() {
  118. console.log(this.list.length < this.total)
  119. if(this.list.length < this.total){
  120. this.status = 'loading';
  121. this.pageNo += 1
  122. this.getbundle()
  123. }else{
  124. this.status = "nomore"
  125. }
  126. },
  127. // 查询列表
  128. getbundle (pageNo) {
  129. if (pageNo) {
  130. this.pageNo = pageNo
  131. }
  132. let params = {
  133. pageNo: this.pageNo,
  134. pageSize: this.pageSize,
  135. }
  136. this.status = "loading"
  137. getCustomerBundle(params).then(res => {
  138. console.log(params,res,'+++++++++++')
  139. if (res.status == 200) {
  140. if(this.pageNo>1){
  141. this.list = this.list.concat(res.data.list || [])
  142. }else{
  143. this.list = res.data.list || []
  144. }
  145. this.total = res.data.count || 0
  146. } else {
  147. this.list = []
  148. this.total = 0
  149. this.noDataText = res.message
  150. }
  151. if(this.list.length<this.total){
  152. this.status = "loadmore"
  153. }else{
  154. this.status = "nomore"
  155. }
  156. })
  157. },
  158. toUser(){
  159. if(!this.hasLogin){
  160. uni.navigateTo({
  161. url:"/pages/login/login"
  162. })
  163. }else{
  164. // 退出登录
  165. this.$refs.openModal.open()
  166. }
  167. },
  168. onOk(){
  169. this.$refs.openModal.close()
  170. this.$store.dispatch('userLogout');
  171. },
  172. toDetail(item){
  173. uni.navigateTo({
  174. url:"/pages/bundelDetail/index?customerBundleId="+item.id+"&bundleName="+item.bundleName
  175. })
  176. }
  177. }
  178. }
  179. </script>
  180. <style lang="less">
  181. .content {
  182. margin: 0;
  183. padding: 0;
  184. height: 100vh;
  185. display: flex;
  186. flex-direction: column;
  187. .ml10{
  188. margin-left: 0.2em;
  189. }
  190. .list-box{
  191. flex-grow: 1;
  192. overflow: auto;
  193. position: relative;
  194. .swiper-item{
  195. width: 100%;
  196. height: 100%;
  197. overflow: hidden;
  198. .scroll-box{
  199. width: 100%;
  200. height: 100%;
  201. overflow: auto;
  202. .item-box{
  203. border-bottom: 1px solid #eee;
  204. padding: 1em;
  205. &:active{
  206. background: #f8f8f8;
  207. }
  208. .l_box{
  209. font-size: 1.1em;
  210. flex: 2;
  211. }
  212. .r_box{
  213. color: #999;
  214. flex: 1;
  215. justify-content: flex-end;
  216. > view{
  217. padding: 0 0.1em;
  218. text-align: right;
  219. }
  220. }
  221. }
  222. .des{
  223. text-align: center;
  224. padding: 3em 0;
  225. color: #999;
  226. font-size: 0.9em;
  227. }
  228. }
  229. }
  230. }
  231. }
  232. </style>