special-item-info.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <template>
  2. <view class="special-item-info-page">
  3. <scroll-view scroll-y class="scroll-content">
  4. <view class="item">
  5. <view class="label">活动状态</view>
  6. <view class="value between">
  7. <view class="curr-status" :class="{ ing: form.status == 1 }">{{ form.status == 1 ? '进行中' : '停止' }}</view>
  8. <view class="update-status" @click="handUpdateStatus">修改状态</view>
  9. </view>
  10. </view>
  11. <view class="item">
  12. <view class="label">活动主题</view>
  13. <view class="value">
  14. {{form.activityName}}
  15. </view>
  16. </view>
  17. <view class="item">
  18. <view class="label">活动描述</view>
  19. <view class="value">
  20. {{form.activityComment}}
  21. </view>
  22. </view>
  23. <view class="item">
  24. <view class="label">活动时间</view>
  25. <view class="value">
  26. {{form.startDate}} ~ {{form.endDate}}
  27. </view>
  28. </view>
  29. <view class="goods-wrap">
  30. <view class="title">参与的商品(不支持多规格商品)</view>
  31. <view class="goods" v-for="item in goodsList" :key="item.storeSpecialGoodsId">
  32. <view class="cover">
  33. <image class="img" :src="item.pictureUrl"/>
  34. </view>
  35. <view class="cont">
  36. <view class="name">{{item.goodsName}}</view>
  37. <view class="tools">
  38. <view class="price">¥{{moneyConverter(item.activityPrice)}}</view>
  39. <view class="origin-price">¥{{moneyConverter(item.costPrice)}}</view>
  40. </view>
  41. <view class="desc">
  42. 每单限购{{item.maxNum}}份,活动库存{{item.activityNum}}份
  43. <br>
  44. 剩余库存{{item.inventory || 0}}份
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </scroll-view>
  50. <view class="update-events">
  51. <view class="btn" @click="deleteActivity">删除</view>
  52. <view class="btn" @click="updateSpecialItem">调整活动内容</view>
  53. </view>
  54. <u-modal
  55. :show="updateStatusVisible"
  56. title="注意"
  57. closeOnClickOverlay
  58. showCancelButton
  59. @confirm="updateStatus"
  60. @close="updateStatusVisible = false"
  61. @cancel="updateStatusVisible = false">
  62. <view class="container">
  63. 活动中的商品如果参加首页推荐,活动状态改变后将会在首页、店铺同步下架,您是否确定改变?
  64. </view>
  65. </u-modal>
  66. </view>
  67. </template>
  68. <script>
  69. import {mapState} from 'vuex';
  70. export default {
  71. data () {
  72. return {
  73. getStoreSpecialActivityByIdUrl: '/storeSpecialActivityApi/getStoreSpecialActivityByIdForStore',
  74. updateStoreSpecialActivityStatusUrl: '/storeSpecialActivityApi/updateStoreSpecialActivityStatusForStore',
  75. deleteStoreSpecialActivityUrl: '/storeSpecialActivityApi/deleteStoreSpecialActivityForStore',
  76. updateStatusVisible: false,
  77. form: {
  78. storeSpecialActivityId: '',
  79. activityName: '',
  80. activityComment: '',
  81. startDate: '',
  82. endDate: '',
  83. status: ''
  84. },
  85. goodsList: []
  86. }
  87. },
  88. computed: {
  89. ...mapState(['storeInfo'])
  90. },
  91. methods: {
  92. loadData() {
  93. uni.showLoading({
  94. title: '加载中'
  95. });
  96. var dateStr = (new Date()).getTime();
  97. var sign = this.getSign('' + this.storeInfo.storeId + dateStr);
  98. this.requst({
  99. url: this.getStoreSpecialActivityByIdUrl,
  100. data: {
  101. timestamp: dateStr,
  102. sign: sign,
  103. storeId: this.storeInfo.storeId,
  104. id: this.form.storeSpecialActivityId
  105. },
  106. success: res => {
  107. this.form = res.data.obj;
  108. this.goodsList = res.data.list;
  109. uni.hideLoading();
  110. },
  111. fail: (e) => {
  112. console.log("接口调用失败:" + JSON.stringify(e));
  113. uni.hideLoading();
  114. },
  115. })
  116. },
  117. deleteActivity() {
  118. if (this.form.status == 1) {
  119. this.$api.msg("进行中的活动不能删除,请先停止活动后再进行删除");
  120. return;
  121. }
  122. let that = this;
  123. uni.showModal({
  124. title: '提示',
  125. content: '确定删除这个特价菜活动吗?',
  126. success: function(res) {
  127. if (res.confirm) {
  128. uni.showLoading({
  129. title: '删除中'
  130. });
  131. var dateStr = (new Date()).getTime();
  132. var sign = that.getSign('' + that.storeInfo.storeId + dateStr);
  133. that.requst({
  134. url: that.deleteStoreSpecialActivityUrl,
  135. data: {
  136. timestamp: dateStr,
  137. sign: sign,
  138. storeId: that.storeInfo.storeId,
  139. id: that.form.storeSpecialActivityId
  140. },
  141. success: res => {
  142. if (res.data.rtnBean.rtnCode == 0) {
  143. uni.showToast({
  144. title: "删除成功",
  145. duration: 3000,
  146. icon: 'none',
  147. });
  148. // uni.redirectTo({
  149. // url: '/pages/activity/special-item'
  150. // })
  151. let pages = getCurrentPages();
  152. let prevpage = pages[pages.length - 2];
  153. prevpage.$vm.getStoreSpecialActivityList();
  154. uni.navigateBack();
  155. } else {
  156. that.$api.msg(res.data.rtnBean.rtnMsg);
  157. }
  158. uni.hideLoading();
  159. },
  160. fail: (e) => {
  161. console.log("接口调用失败:" + JSON.stringify(e));
  162. uni.hideLoading();
  163. },
  164. })
  165. }
  166. }
  167. });
  168. },
  169. handUpdateStatus() {
  170. if (this.form.status == 1) {
  171. this.updateStatusVisible = true
  172. return;
  173. }
  174. this.updateStatus();
  175. },
  176. updateStatus () {
  177. uni.showLoading({
  178. title: '更新中'
  179. });
  180. this.updateStatusVisible = false;
  181. var dateStr = (new Date()).getTime();
  182. var sign = this.getSign('' + this.storeInfo.storeId + dateStr);
  183. this.requst({
  184. url: this.updateStoreSpecialActivityStatusUrl,
  185. data: {
  186. timestamp: dateStr,
  187. sign: sign,
  188. storeId: this.storeInfo.storeId,
  189. id: this.form.storeSpecialActivityId,
  190. status: this.form.status == 1 ? 0 : 1
  191. },
  192. success: res => {
  193. if (res.data.rtnBean.rtnCode == 0) {
  194. this.$api.msg("更新成功");
  195. } else {
  196. this.$api.msg(res.data.rtnBean.rtnMsg);
  197. }
  198. this.loadData();
  199. uni.hideLoading();
  200. },
  201. fail: (e) => {
  202. console.log("接口调用失败:" + JSON.stringify(e));
  203. uni.hideLoading();
  204. },
  205. })
  206. },
  207. updateSpecialItem () {
  208. if (this.form.status == 1) {
  209. this.$api.msg("进行中的活动不能编辑,请先停止活动后再进行编辑");
  210. return;
  211. }
  212. uni.navigateTo({
  213. url: `/pages/activity/special-item-edit?id=${this.form.storeSpecialActivityId}`
  214. });
  215. }
  216. },
  217. onLoad (options) {
  218. if (options && options.id) {
  219. this.form.storeSpecialActivityId = options.id;
  220. this.loadData();
  221. }
  222. }
  223. }
  224. </script>
  225. <style lang="scss" scoped>
  226. .special-item-info-page {
  227. background-color: #f5f5f5;
  228. border-top: 2rpx solid #f5f5f5;
  229. width: 100vw;
  230. height: 100vh;
  231. }
  232. .scroll-content {
  233. height: calc(100vh - 120rpx - env(safe-area-inset-bottom));
  234. height: calc(100vh - 120rpx - constant(safe-area-inset-bottom));
  235. }
  236. .item:first-child {
  237. padding-top: 40rpx;
  238. }
  239. .item {
  240. @include flexStart;
  241. background-color: #fff;
  242. padding: 20rpx 40rpx;
  243. box-sizing: border-box;
  244. font-size: $font-base;
  245. .label {
  246. width: 240rpx;
  247. color: $desc-color;
  248. }
  249. .value {
  250. width: calc(100% - 240rpx);
  251. @include between;
  252. // overflow: hidden;
  253. // text-overflow: ellipsis;
  254. // word-break: break-all;
  255. // white-space: nowrap;
  256. }
  257. .left {
  258. @include flexStart;
  259. }
  260. .curr-status {
  261. color: $theme-color;
  262. }
  263. .curr-status.ing {
  264. color: $uni-color-button;
  265. }
  266. .update-status {
  267. height: 54rpx;
  268. width: 160rpx;
  269. background-color: $theme-color;
  270. color: #fff;
  271. @include flexCenter;
  272. border-radius: 27rpx;
  273. }
  274. }
  275. .goods-wrap {
  276. .title {
  277. height: 80rpx;
  278. @include flexStart;
  279. padding-left: 40rpx;
  280. box-sizing: border-box;
  281. font-size: $font-base;
  282. color: $text-color;
  283. }
  284. }
  285. .goods {
  286. background-color: #fff;
  287. @include flexStart;
  288. padding: 20rpx;
  289. box-sizing: border-box;
  290. .cover {
  291. width: 166rpx;
  292. height: 166rpx;
  293. border-radius: 10rpx;
  294. margin-right: 24rpx;
  295. .img {
  296. width: 166rpx;
  297. height: 166rpx;
  298. }
  299. }
  300. .cont {
  301. width: calc(100% - 200rpx);
  302. font-size: $font-base;
  303. height: 166rpx;
  304. overflow: hidden;
  305. }
  306. .name {
  307. width: 100%;
  308. text-overflow: -o-ellipsis-lastline;
  309. overflow: hidden;
  310. text-overflow: ellipsis;
  311. display: -webkit-box;
  312. -webkit-line-clamp: 2;
  313. -webkit-box-orient: vertical;
  314. }
  315. .tools {
  316. @include flexStart;
  317. }
  318. .price {
  319. margin-right: 40rpx;
  320. color: $uni-color-button;
  321. }
  322. .origin-price {
  323. color: $desc-color;
  324. text-decoration:line-through;
  325. }
  326. .desc {
  327. color: $desc-color;
  328. }
  329. }
  330. .container {
  331. font-size: $font-base;
  332. }
  333. .update-events {
  334. width: 100vw;
  335. @include flexCenter;
  336. margin-top: 40rpx;
  337. .btn {
  338. width: 80vw;
  339. height: 80rpx;
  340. border-radius: 40rpx;
  341. background-color: $theme-color;
  342. color: #fff;
  343. @include flexCenter;
  344. margin-left: 20rpx;
  345. margin-right: 20rpx;
  346. }
  347. }
  348. </style>