special-item.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view class="special-item-page">
  3. <scroll-view class="list-wrap" scroll-y>
  4. <view class="item" v-for="item in activityList" :key="item.storeSpecialActivityId" @click="handItem(item)">
  5. <view class="cover">
  6. <image class="icon" src="../../static/imgs/mine/tjc.png"/>
  7. </view>
  8. <view class="cont">
  9. <view class="row">
  10. <view class="name">{{item.activityName}}</view>
  11. <view class="date">{{item.startDate|formatDate('MM.dd')}} ~ {{item.endDate|formatDate('MM.dd')}}</view>
  12. </view>
  13. <view class="row">
  14. <view class="desc">
  15. {{item.activityComment}}
  16. </view>
  17. <view v-if="item.status==1" class="status">进行中</view>
  18. <view v-else class="status-unused">停止</view>
  19. </view>
  20. </view>
  21. </view>
  22. </scroll-view>
  23. <view class="add-special-item">
  24. <view class="add" @click="addSpecialItem">添加特价菜活动</view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import {mapState} from 'vuex';
  30. export default {
  31. data () {
  32. return {
  33. getStoreSpecialActivityListUrl: '/storeSpecialActivityApi/getStoreSpecialActivityListForStore',
  34. activityList: []
  35. }
  36. },
  37. computed: {
  38. ...mapState(['storeInfo'])
  39. },
  40. methods: {
  41. handItem(item) {
  42. uni.navigateTo({
  43. url: '/pages/activity/special-item-info?id=' + item.storeSpecialActivityId
  44. });
  45. },
  46. addSpecialItem () {
  47. if (this.activityList.length >= 5) {
  48. this.$api.msg("最多只能创建五个活动,请先删除不需要的活动");
  49. return;
  50. } else {
  51. uni.navigateTo({
  52. url: '/pages/activity/special-item-edit'
  53. });
  54. }
  55. },
  56. getStoreSpecialActivityList() {
  57. uni.showLoading({
  58. title: '加载中'
  59. });
  60. var dateStr = (new Date()).getTime();
  61. var sign = this.getSign('' + this.storeInfo.storeId + dateStr);
  62. this.requst({
  63. url: this.getStoreSpecialActivityListUrl,
  64. data: {
  65. timestamp: dateStr,
  66. sign: sign,
  67. storeId: this.storeInfo.storeId
  68. },
  69. success: res => {
  70. this.activityList = res.data.list;
  71. uni.hideLoading();
  72. },
  73. fail: (e) => {
  74. console.log("接口调用失败:" + JSON.stringify(e));
  75. uni.hideLoading();
  76. },
  77. })
  78. }
  79. },
  80. onShow () {
  81. this.getStoreSpecialActivityList();
  82. }
  83. }
  84. </script>
  85. <style lang="scss" scoped>
  86. .special-item-page {
  87. width: 100vw;
  88. height: 100vh;
  89. background-color: #f5f5f5;
  90. overflow: hidden;
  91. }
  92. .list-wrap {
  93. height: calc(100vh - 140rpx - env(safe-area-inset-bottom));
  94. height: calc(100vh - 140rpx - constant(safe-area-inset-bottom));
  95. margin-top: 20rpx;
  96. .item {
  97. margin-bottom: 20rpx;
  98. background-color: #fff;
  99. padding: 40rpx;
  100. box-sizing: border-box;
  101. @include flexStart;
  102. }
  103. .cover {
  104. min-width: 60rpx;
  105. width: 60rpx;
  106. height: 60rpx;
  107. margin-right: 40rpx;
  108. border-radius: 50%;
  109. overflow: hidden;
  110. @include flexCenter;
  111. box-shadow: 0 0 10rpx pink;
  112. }
  113. .icon {
  114. width: 42rpx;
  115. height: 42rpx;
  116. }
  117. .cont {
  118. width: calc(100% - 100rpx);
  119. font-size: $font-base;
  120. }
  121. .row {
  122. width: 100%;
  123. @include between;
  124. margin-bottom: 10rpx;
  125. }
  126. .name {
  127. color: $text-color;
  128. width: calc(100% - 240rpx);
  129. overflow: hidden;
  130. text-overflow: ellipsis;
  131. white-space: nowrap;
  132. word-break: break-all;
  133. }
  134. .date {
  135. width: 240rpx;
  136. text-align: right;
  137. }
  138. .desc {
  139. color: $desc-color;
  140. }
  141. .status {
  142. width: 240rpx;
  143. text-align: right;
  144. color: $uni-color-button;
  145. }
  146. .status-unused {
  147. width: 240rpx;
  148. text-align: right;
  149. color: $theme-color;
  150. }
  151. }
  152. .add-special-item {
  153. width: 100vw;
  154. @include flexCenter;
  155. margin-top: 40rpx;
  156. .add {
  157. width: 80vw;
  158. height: 80rpx;
  159. border-radius: 40rpx;
  160. background-color: $theme-color;
  161. color: #fff;
  162. @include flexCenter;
  163. }
  164. }
  165. </style>