index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <view class="activity">
  3. <!-- #ifdef MP-ALIPAY -->
  4. <u-navbar title="拼团抽奖" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" leftIconSize="0" />
  5. <!-- #endif -->
  6. <!-- #ifdef MP-WEIXIN -->
  7. <u-navbar title="拼团抽奖" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
  8. <!-- #endif -->
  9. <!-- #ifndef MP-WEIXIN || MP-ALIPAY -->
  10. <view v-if="pagesNum > 1">
  11. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="拼团抽奖" />
  12. </view>
  13. <view v-else>
  14. <u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" :border="true" title="拼团抽奖">
  15. <view class="nav-left flex" slot="left" @click="$toIndex()">
  16. <u-icon name="arrow-left" size="20" color="#333"></u-icon>
  17. </view>
  18. </u-navbar>
  19. </view>
  20. <!-- #endif -->
  21. <view class="status">
  22. <u-tabs @change="changeTab" :scrollable="false" :list="statusArr" lineWidth="34" lineHeight="3"
  23. lineColor="#8E51F7" :activeStyle="{
  24. color: '#8E51F7',
  25. transform: 'scale(1)',
  26. width: '150rpx',
  27. }" :inactiveStyle="{
  28. color: '#666',
  29. transform: 'scale(1)',
  30. width: '150rpx'
  31. }" itemStyle="padding-left: 11px; padding-right: 11px; height: 44px;text-align: center; ">
  32. </u-tabs>
  33. </view>
  34. <view class="list">
  35. <view v-for="(item,index) in list1" :key="index" class="list-view">
  36. <view class="lottery-inner" @click='toGroup()'>
  37. <view class="lottery-img">
  38. <image src="../../static/public/111.jpg" mode=""></image>
  39. </view>
  40. <view class="lottery-msg">
  41. <view class="lottery-title">轩妈蛋黄酥40g*4枚2袋装随心装</view>
  42. <view class="lottery-time">2023-12-31 12:00:00 截止</view>
  43. <view class="lottery-person">已拼4人</view>
  44. <view class="lottery-price"><text>¥</text>0.01</view>
  45. <button class="toGroup" >去拼团</button>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="flex empty" v-if="!list.length && !loading && triggerStatus == 0">
  50. <view class="center">
  51. <image class="center-img"
  52. src="https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/static/lucky_empty_list.png" mode="scaleToFill"></image>
  53. <view class="center-font">新的活动正在准备中...</view>
  54. </view>
  55. </view>
  56. <view class="flex empty" v-if="!list.length && !loading && triggerStatus != 0">
  57. <view class="center">
  58. <image class="center-img"
  59. src="https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/static/lucky_empty_list.png" mode="scaleToFill"></image>
  60. <view class="center-font">还没有已开奖活动</view>
  61. </view>
  62. </view>
  63. </view>
  64. <u-loadmore :line="true" v-if="list.length>5" :status="status" :loading-text="'努力加载中'" :nomore-text="'已经到底了'" />
  65. <!-- <custom-tab-bar :activeValue="'activity'" /> -->
  66. </view>
  67. </template>
  68. <script>
  69. import env from '../../config/env.js'
  70. import $http from '@/utils/request.js'
  71. import appId from '@/config/appId.js'
  72. import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
  73. export default {
  74. components: {
  75. CustomTabBar,
  76. },
  77. data() {
  78. return {
  79. status: 'nomore',//上拉刷新状态
  80. list: [],
  81. list1: [1,2,3,4],
  82. statusArr: [{
  83. name: '进行中'
  84. }, {
  85. name: '预热中',
  86. }, {
  87. disabled: true
  88. }, {
  89. disabled: true
  90. }, {
  91. disabled: true
  92. }],
  93. triggerStatus: 0,
  94. userInfo: '',
  95. pageNum: 1,
  96. total: 0,
  97. }
  98. },
  99. onLoad(opthios) {
  100. if (opthios.triggerStatus) {
  101. this.triggerStatus = opthios.triggerStatus
  102. }
  103. if (opthios.userId) {
  104. uni.setStorageSync('shareUid', opthios.userId != 'undefined'?opthios.userId:null)
  105. if (opthios.userId === undefined || opthios.userId === 'undefined') {
  106. uni.getSystemInfo({
  107. success(res) {
  108. log.error(
  109. `基础库:${ res.SDKVersion },设备:${ res.model }-${ res.system },页面:/pages/activity/index.vue.`
  110. )
  111. }
  112. })
  113. }
  114. }
  115. if (opthios.type) {
  116. uni.setStorageSync('shareType', opthios.type)
  117. }
  118. },
  119. onShow() {
  120. if(uni.getStorageSync('token')) {
  121. this.getBaseInfo()
  122. }
  123. this.pageList()
  124. },
  125. methods: {
  126. toRecord(item) {
  127. if (!uni.getStorageSync('token')) {
  128. uni.navigateTo({
  129. url: '/pages/login/index'
  130. })
  131. return
  132. }
  133. uni.navigateTo({
  134. url: item.status.value == 4 ? `/packageOperate/lottery/record?id=${ item.id }` :
  135. `/packageOperate/lottery/details?id=${ item.id }`
  136. })
  137. },
  138. toGroup(){
  139. uni.navigateTo({
  140. url: "/packageOperate/lottery/details"
  141. })
  142. },
  143. changeTab(e) {
  144. if (e.index == 0) {
  145. this.triggerStatus = 0
  146. this.status = 'nomore'
  147. } else if (e.index == 1) {
  148. this.triggerStatus = 1
  149. this.status = 'nomore'
  150. }
  151. this.pageList()
  152. },
  153. pageList() {
  154. this.pageNum = 1
  155. this.total = 0
  156. this.list = []
  157. this.getList()
  158. },
  159. getList() {
  160. this.loading = true
  161. $http.post(`/api/v1/mp/user/marketing/list?pageNum=${this.pageNum}&pageSize=5`, {
  162. triggerStatus: this.triggerStatus,
  163. }).then(res => {
  164. this.loading = false
  165. if (res.code == 0) {
  166. res.rows.forEach(item => {
  167. let picUrlArr = item.picUrl.split(',')
  168. item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/750'
  169. item.status = JSON.parse(item.status)
  170. })
  171. this.total = res.total
  172. this.list = this.list.concat(res.rows)
  173. }
  174. }).catch(() => {
  175. this.loading = false
  176. })
  177. },
  178. getBaseInfo() {
  179. $http.post('/api/v1/mp/user/getLoginUserinfo', { appSource: appId }).then(res => {
  180. uni.hideLoading();
  181. if (res.code == 0) {
  182. this.userInfo = res.data
  183. }
  184. })
  185. },
  186. },
  187. //分享好友
  188. onShareAppMessage(res) {
  189. return {
  190. title: '共富券,玩的就是有趣',
  191. path: '/pages/index/index'
  192. }
  193. },
  194. //分享朋友圈
  195. onShareTimeline() {
  196. return {
  197. title: '共富券,玩的就是有趣',
  198. query: `userId=${ this.userInfo.userId?this.userInfo.userId:null }&type=1`
  199. }
  200. },
  201. onReachBottom() {
  202. if(this.total < this.pageNum * 5) return ;
  203. this.status = 'loading';
  204. ++this.pageNum
  205. if(this.total < this.pageNum * 5) this.status = 'nomore';
  206. else this.status = 'loading';
  207. this.getList()
  208. },
  209. }
  210. </script>
  211. <style lang="scss" scoped>
  212. .activity {
  213. width: 100%;
  214. height: 100%;
  215. // 设置ios刘海屏底部横线安全区域
  216. padding-bottom: constant(safe-area-inset-bottom);
  217. padding-bottom: env(safe-area-inset-bottom);
  218. }
  219. .lottery-inner{
  220. width: 700rpx;
  221. margin: auto;
  222. background: #fff;
  223. overflow: hidden;
  224. margin-bottom: 20rpx;
  225. border-radius: 10rpx;
  226. .lottery-img{
  227. width: 200rpx;
  228. float: left;
  229. padding: 5rpx;
  230. image{
  231. width: 100%;
  232. height: 220rpx;
  233. }
  234. }
  235. .lottery-msg{
  236. margin-left: 220rpx;
  237. padding: 15rpx 0rpx;
  238. position: relative;
  239. .lottery-title{
  240. font-size: 30rpx;
  241. color: #000000;
  242. font-weight: 500;
  243. margin-bottom: 10rpx;
  244. }
  245. .lottery-time{
  246. font-size: 28rpx;
  247. color: #666666;
  248. margin-bottom: 5rpx;
  249. }
  250. .lottery-person{
  251. font-size: 28rpx;
  252. color: #666666;
  253. margin-bottom: 20rpx;
  254. }
  255. .lottery-price{
  256. color: red;
  257. font-size: 34rpx;
  258. text{
  259. font-size: 24rpx;
  260. margin-right: 5rpx;
  261. }
  262. }
  263. .toGroup{
  264. width: 142rpx;
  265. height: 58rpx;
  266. line-height: 58rpx;
  267. background-color: #8E51F7;
  268. color: #fff;
  269. margin-top: 34rpx;
  270. font-size: 28rpx;
  271. border-radius: 8rpx;
  272. display: block;
  273. text-align: center;
  274. position: absolute;
  275. right: 20rpx;
  276. bottom: 20rpx;
  277. }
  278. }
  279. }
  280. .status {
  281. width: 100%;
  282. position: fixed;
  283. z-index: 100;
  284. background-color: #FFFFFF;
  285. box-shadow: 0 5rpx 5rpx #ececec;
  286. }
  287. .list {
  288. padding: 120rpx 20rpx 0;
  289. }
  290. .empty {
  291. height: 60vh;
  292. .center {
  293. text-align: center;
  294. &-img {
  295. width: 228rpx;
  296. height: 320rpx;
  297. }
  298. &-font {
  299. font-size: 30rpx;
  300. font-weight: 400;
  301. color: #999999;
  302. margin-bottom: 250rpx;
  303. }
  304. }
  305. }
  306. .price{
  307. float: right;
  308. color: red;
  309. font-size: 40rpx;
  310. }
  311. </style>