full-discounts.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <view class="coupon-page">
  3. <scroll-view scroll-y class="form-wrap">
  4. <view class="cell">
  5. <view class="label">活动状态</view>
  6. <view class="value">
  7. <view class="status-name" :class="{ ing: fullDiscounts.fullDiscountsStatus == 1 }" v-if=" this.fullDiscounts.roleList !=null && this.fullDiscounts.roleList.length > 0">{{ fullDiscounts.fullDiscountsStatus == 1 ? '进行中' : '已失效' }}</view>
  8. <view class="status-name" v-if="this.fullDiscounts.roleList ==null || this.fullDiscounts.roleList.length == 0">暂无满减活动</view>
  9. <view class="update-status" @click="changeStatus" v-if="this.fullDiscounts.roleList !=null && this.fullDiscounts.roleList.length > 0">修改状态</view>
  10. <view class="add-activity" @click="updateFull" v-if="this.fullDiscounts.roleList ==null || this.fullDiscounts.roleList.length == 0">添加活动</view>
  11. </view>
  12. </view>
  13. <view class="cell">
  14. <view class="label">活动时间</view>
  15. <view class="value" v-if="fullDiscounts.fullDiscountsStartDateStr != null && fullDiscounts.fullDiscountsStartDateStr != undefined">
  16. {{ fullDiscounts.fullDiscountsStartDateStr }} ~ {{ fullDiscounts.fullDiscountsEndDateStr }}
  17. </view>
  18. </view>
  19. <view class="cell mb40" :style="'height:'+height+'rpx;'">
  20. <view class="label">满减规则</view>
  21. <view class="value column" >
  22. <view class="rule" v-for="(item, index) in fullDiscounts.roleList" :key="fullDiscountsRoleId" >满{{ item.conditionFee}}减{{ item.discountsFee }}</view>
  23. <!-- <view class="rule">满50减10</view> -->
  24. </view>
  25. </view>
  26. <view class="cell">
  27. <view class="label">创建日期</view>
  28. <view class="value">{{ fullDiscounts.createDateStr || '' }}</view>
  29. </view>
  30. </scroll-view>
  31. <view class="update-events" v-if=" this.fullDiscounts.roleList !=null && this.fullDiscounts.roleList.length > 0">
  32. <view class="btn" @click="updateFull">调整满减活动</view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import { mapState } from 'vuex';
  38. export default {
  39. data () {
  40. return {
  41. fullDiscountsUrl: '/storeFullDiscountsManageApi/getDiscountsInfo',
  42. changeStatusUrl: '/storeFullDiscountsManageApi/changeStatus',
  43. fullDiscounts: {},
  44. height: 40
  45. }
  46. },
  47. computed: {
  48. ...mapState(['storeInfo'])
  49. },
  50. methods: {
  51. loadData () {
  52. uni.showLoading({
  53. title: '加载中'
  54. });
  55. var dateStr = (new Date()).getTime();
  56. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  57. this.requst({
  58. url: this.fullDiscountsUrl,
  59. data: {
  60. timestamp: dateStr,
  61. sign: sign,
  62. storeId: this.storeInfo.storeId,
  63. storeUserId: this.storeInfo.storeUserId
  64. },
  65. success: res => {
  66. if (res.data.rtnBean.rtnCode == 0) {
  67. this.fullDiscounts = res.data.obj;
  68. if(this.fullDiscounts.roleList != null && this.fullDiscounts.roleList.length > 0){
  69. this.height = 40 * this.fullDiscounts.roleList.length
  70. }
  71. }
  72. uni.hideLoading();
  73. },
  74. fail: (e) => {
  75. console.log("接口调用失败:" + JSON.stringify(e));
  76. uni.hideLoading();
  77. }
  78. })
  79. },
  80. changeStatus() {
  81. uni.showLoading({
  82. title: '加载中'
  83. });
  84. this.fullDiscounts.fullDiscountsStatus = this.fullDiscounts.fullDiscountsStatus == 1 ? 0 : 1
  85. var dateStr = (new Date()).getTime();
  86. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  87. this.requst({
  88. url: this.changeStatusUrl,
  89. data: {
  90. timestamp: dateStr,
  91. sign: sign,
  92. storeId: this.storeInfo.storeId,
  93. storeUserId: this.storeInfo.storeUserId,
  94. status: this.fullDiscounts.fullDiscountsStatus
  95. },
  96. success: res => {
  97. if (res.data.rtnBean.rtnCode == 0) {
  98. this.loadData();
  99. }
  100. uni.hideLoading();
  101. },
  102. fail: (e) => {
  103. console.log("接口调用失败:" + JSON.stringify(e));
  104. uni.hideLoading();
  105. }
  106. })
  107. },
  108. updateFull () {
  109. if(this.fullDiscounts.fullDiscountsStatus == 1 ){
  110. this.$api.msg("进行中的活动无法调整");
  111. return;
  112. }
  113. uni.navigateTo({
  114. url: `/pages/activity/update-full-discounts`
  115. });
  116. }
  117. },
  118. onShow () {
  119. },
  120. onLoad() {
  121. this.loadData();
  122. }
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. .coupon-page {
  127. border-top: 2rpx solid #f5f5f5;
  128. height: 100vh;
  129. background-color: #f5f5f5;
  130. }
  131. .update-events {
  132. width: 100vw;
  133. @include flexCenter;
  134. margin-top: 40rpx;
  135. .btn {
  136. width: 80vw;
  137. height: 80rpx;
  138. border-radius: 40rpx;
  139. background-color: $theme-color;
  140. color: #fff;
  141. @include flexCenter;
  142. }
  143. }
  144. .form-wrap {
  145. background-color: #fff;
  146. padding: 40rpx;
  147. box-sizing: border-box;
  148. height: calc(100vh - 120rpx - env(safe-area-inset-bottom));
  149. height: calc(100vh - 120rpx - constant(safe-area-inset-bottom));
  150. .cell {
  151. @include flexStart(flex-start);
  152. height: 80rpx;
  153. font-size: $font-base;
  154. }
  155. .label {
  156. color: $desc-color;
  157. width: 200rpx;
  158. }
  159. .status-name {
  160. color: $theme-color;
  161. }
  162. .status-name.ing {
  163. color: $uni-color-button;
  164. }
  165. .update-status {
  166. width: 180rpx;
  167. height: 52rpx;
  168. border-radius: 26rpx;
  169. @include flexCenter;
  170. color: #fff;
  171. background-color: $theme-color;
  172. }
  173. .add-activity {
  174. width: 180rpx;
  175. height: 52rpx;
  176. border-radius: 26rpx;
  177. margin-right: 10rpx;
  178. @include flexCenter;
  179. float: right;
  180. // display: flex;
  181. // justify-content: center;
  182. // align-items: flex-start;
  183. color: #fff;
  184. background-color: $theme-color;
  185. }
  186. .value {
  187. width: calc(100% - 200rpx);
  188. @include between(flex-start);
  189. color: $text-color;
  190. // width: calc(100% - 200rpx);
  191. // /* display: flex; */
  192. // justify-content: space-between;
  193. // align-items: flex-start;
  194. // color: $text-color;
  195. }
  196. .rule {
  197. margin-bottom: 10rpx;
  198. }
  199. .column {
  200. display: flex;
  201. flex-direction: column;
  202. align-items: flex-start;
  203. justify-content: flex-start;
  204. }
  205. .mb40 {
  206. margin-bottom: 40rpx;
  207. }
  208. }
  209. </style>