index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view>
  3. <!-- #ifdef MP-ALIPAY -->
  4. <!-- <u-navbar :title="siteName" :border="true" :placeholder="true" bgColor="#fff" leftIconSize="0" /> -->
  5. <u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" :title="siteName">
  6. <view class="nav-left flex" slot="left" @click="$toIndex()">
  7. <u-icon name="home" size="20" color="#333"></u-icon>
  8. <view class="nav-left__code">首页</view>
  9. </view>
  10. </u-navbar>
  11. <!-- #endif -->
  12. <!-- #ifndef MP-ALIPAY -->
  13. <!-- <u-navbar :title="siteName" :border="true" :placeholder="true" leftIconSize="0" bgColor="#fff" /> -->
  14. <u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" :title="siteName">
  15. <view class="nav-left flex" slot="left" @click="$toIndex()">
  16. <u-icon name="home" size="20" color="#333"></u-icon>
  17. <view class="nav-left__code">首页</view>
  18. </view>
  19. </u-navbar>
  20. <!-- #endif -->
  21. <view class="list">
  22. <view class="list-item" v-for="(item, index) in list" :key="index">
  23. <image :src="item.picUrl" mode="aspectFit" @click="toTicketBox(item)"></image>
  24. <view class="list-item-content flex" @click="toTicketBox(item)">
  25. <view class="top">{{ item.title }}</view>
  26. <view class="bottom flex">
  27. <view class="bottom-price">价格:<view style="font-size: 12px; display: inline-block;">¥</view>{{ $numberFormat(item.salePrice) }}<view class="view1" v-if="item.originPrice"><text style="font-size: 10px; display: inline-block;">¥</text>{{ $numberFormat(item.originPrice) }}</view></view>
  28. </view>
  29. </view>
  30. </view>
  31. <u-loadmore :line="true" v-if="list.length > 5" :status="status" :loading-text="'努力加载中'" :nomore-text="'已经到底了'" />
  32. </view>
  33. <view class="flex empty" v-if="!list.length">
  34. <view class="center">
  35. <image class="center-img" src="https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/nodata_3.png" mode="scaleToFill"></image>
  36. <view class="center-font">暂无盲票</view>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import env from '../../config/env.js'
  43. import $http from '@/utils/request.js'
  44. export default {
  45. data() {
  46. return {
  47. status: 'nomore',//上拉刷新状态
  48. pageNum: 1,
  49. total: 0,
  50. list: [],
  51. pagesNum: '',
  52. sceneArr: [],
  53. channelId: '',
  54. userId: '',
  55. siteName: '门店',
  56. }
  57. },
  58. onLoad(options) {
  59. // 测试用
  60. if(options.channelId){
  61. this.channelId = options.channelId
  62. }
  63. /**
  64. * 票赢天下小程序分享门店二维码跳转接收的参数
  65. * channelId: 门店ID
  66. * userId: 分享类型
  67. * siteName: 门店名称
  68. * */
  69. if (options.scene) {
  70. let sceneStr = decodeURIComponent(options.scene)
  71. this.sceneArr = sceneStr.split('&')
  72. this.channelId = this.sceneArr[0]
  73. this.userId = this.sceneArr[1]
  74. }
  75. },
  76. onShow() {
  77. // 获取页面数据
  78. this.pageList()
  79. this.getSiteName()
  80. },
  81. methods: {
  82. //获取门店名称
  83. getSiteName() {
  84. $http.post(`/api/v1/mp/channel/saleSite/info/${this.channelId}`,{}).then(res => {
  85. if (res.code == 0) {
  86. this.siteName = res.data ? res.data : ('门店' + this.channelId)
  87. }
  88. }).catch(() => {
  89. })
  90. },
  91. // 获取页面数据
  92. pageList() {
  93. this.pageNum = 1
  94. this.list = []
  95. this.getList()
  96. },
  97. getList() {
  98. $http.post(`/api/v1/mp/user/ticket/list/underChannel?pageNum=${this.pageNum}&pageSize=20`,{
  99. channelId: this.channelId
  100. }).then(res => {
  101. if (res.code == 0) {
  102. res.rows.forEach(item => {
  103. item.picUrl = env.filePublic + item.picUrl.split(',')[0] + '?imageView2/2/w/170'
  104. })
  105. this.total = res.total
  106. this.list = this.list.concat(res.rows)
  107. }
  108. }).catch(() => {
  109. })
  110. },
  111. // 点击盲票,跳转盲票详情
  112. toTicketBox(item) {
  113. uni.navigateTo({
  114. url: `/pages/ticketBox/detail?boxId=${ item.boxId }&share=1&siteId=${ this.channelId }`
  115. })
  116. },
  117. },
  118. onReachBottom() {
  119. if(this.total < this.pageNum * 20) return ;
  120. this.status = 'loading';
  121. ++this.pageNum
  122. if(this.total < this.pageNum * 20) this.status = 'nomore';
  123. else this.status = 'loading';
  124. this.getList()
  125. },
  126. }
  127. </script>
  128. <style lang="scss" scoped>
  129. .nav-left {
  130. &__code {
  131. margin-left: 10rpx;
  132. }
  133. }
  134. // 状态
  135. .state {
  136. display: flex;
  137. position: fixed;
  138. background-color: #FFFFFF;
  139. width: 100%;
  140. z-index: 10;
  141. box-shadow: 0 5rpx 5rpx #ececec;
  142. }
  143. // 列表
  144. .list {
  145. padding: 20rpx 0 100rpx;
  146. margin: 0 20rpx 0;
  147. &-item {
  148. display: flex;
  149. background: #FFFFFF;
  150. padding: 30rpx 20rpx;
  151. border-radius: 1px;
  152. box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.12);
  153. margin-bottom: 28rpx;
  154. image {
  155. width: 140rpx;
  156. height: 189rpx;
  157. border-radius: 22rpx;
  158. margin-right: 60rpx;
  159. }
  160. &-content {
  161. width: 70%;
  162. // flex: 1;
  163. flex-direction: column;
  164. justify-content: space-between;
  165. padding: 26rpx 0;
  166. .top {
  167. width: 100%;
  168. display: inline-block;
  169. font-size: 30rpx;
  170. line-height: 30rpx;
  171. font-weight: bold;
  172. margin-bottom: 46rpx;
  173. overflow: hidden;
  174. text-overflow: ellipsis;
  175. white-space: nowrap;
  176. }
  177. .bottom {
  178. width: 100%;
  179. justify-content: space-between;
  180. &-price {
  181. height: 30rpx;
  182. overflow: hidden;
  183. font-size: 30rpx;
  184. line-height: 30rpx;
  185. .view1 {
  186. color: #999;
  187. display: inline-block;
  188. text-decoration: line-through;
  189. margin-left: 10rpx;
  190. font-size: 24rpx;
  191. text {
  192. text-decoration: line-through;
  193. }
  194. }
  195. }
  196. }
  197. }
  198. }
  199. }
  200. .empty {
  201. height: 60vh;
  202. .center {
  203. text-align: center;
  204. &-img {
  205. width: 228rpx;
  206. height: 320rpx;
  207. }
  208. &-font {
  209. font-size: 30rpx;
  210. font-weight: 400;
  211. color: #999999;
  212. margin-bottom: 250rpx;
  213. }
  214. }
  215. }
  216. </style>