overlord-meal-detail.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. <template>
  2. <view class="overlord-meal-detail-page" @touchmove.stop.prevent="moveHandle">
  3. <view class="scroll-content">
  4. <image class="banner" :src="form.imgUrl"></image>
  5. <view class="item">
  6. <view class="label">活动状态</view>
  7. <view class="value" :class="{ing: form.status == 1}">{{ form.status == 1 ? '进行中' : (form.status == 0 ? '未开始' : '已失效')}}</view>
  8. </view>
  9. <view class="item">
  10. <view class="label">活动主题</view>
  11. <view class="value">{{form.title}}</view>
  12. </view>
  13. <view class="item">
  14. <view class="label">活动时间</view>
  15. <view class="value">{{form.startDate}} ~ {{form.endDate}}</view>
  16. </view>
  17. <view class="item">
  18. <view class="label">最低单价</view>
  19. <view class="value">¥{{moneyConverter(form.price)}}</view>
  20. </view>
  21. <view class="item">
  22. <view class="label">最低总价</view>
  23. <view class="value">¥{{moneyConverter(form.activityPrice)}}</view>
  24. </view>
  25. <view class="item">
  26. <view class="label">活动达标金额</view>
  27. <view class="value">¥{{moneyConverter(form.reachPrice)}}</view>
  28. </view>
  29. <view v-if="doflg" class="cy-goods">参与的商品</view>
  30. <view v-if="doflg" class="goods">
  31. <view class="cover">
  32. <image class="img" :src="form.pictureUrl"/>
  33. </view>
  34. <view class="cont">
  35. <view class="name">{{form.goodsName}}</view>
  36. <view class="tools">
  37. <view class="price">¥{{moneyConverter(form.salePrice)}}</view>
  38. <view class="origin-price" v-if="form.salePrice < form.costPrice">¥{{moneyConverter(form.costPrice)}}</view>
  39. </view>
  40. <view class="desc">
  41. 未兑换数量{{form.residueNum}}份,参加活动数量{{form.total}}份
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="footer-btn" @touchmove.stop.prevent="moveHandle">
  47. <view class="logout" @click="signUp" v-if="joinBtnVisible">
  48. 报名
  49. </view>
  50. </view>
  51. <u-modal
  52. :show="joinActivityVisible"
  53. title="报名活动"
  54. showCancelButton
  55. @confirm="joinActivity"
  56. @cancel="joinActivityVisible = false"
  57. @close="joinActivityVisible = false">
  58. <view class="container">
  59. <view class="item">
  60. <view class="label">{{goods.goodsName ? goods.goodsName : '选择商品'}}</view>
  61. <view class="value" @click="chooseGoods">
  62. <u-icon name="arrow-right"></u-icon>
  63. </view>
  64. </view>
  65. <view class="item">
  66. <view class="label">价格</view>
  67. <view class="value">
  68. ¥{{moneyConverter(goods.activityPrice)}}
  69. </view>
  70. </view>
  71. <view class="item">
  72. <view class="label">参加活动数量</view>
  73. <view class="value">
  74. <u-input border="none" inputAlign="right" fontSize="14" v-model="goods.activityNum" placeholder="数量"></u-input>
  75. <text class="text">份</text>
  76. </view>
  77. </view>
  78. </view>
  79. </u-modal>
  80. <u-modal
  81. :show="chooseGoodsVisible"
  82. :showConfirmButton="false"
  83. closeOnClickOverlay
  84. @close="chooseGoodsVisible = false">
  85. <view class="modal-container">
  86. <view class="search-wrap">
  87. <view class="input-wrap">
  88. <u-input border="none" fontSize="14" v-model="goodsName" placeholder="商品名称"></u-input>
  89. </view>
  90. <view class="btn" @click="getGoodsList">搜索</view>
  91. </view>
  92. <scroll-view scroll-y class="goods-list">
  93. <view class="goods-item" v-for="item in goodsList" :key="item.goodsId" @click="handItem(item)">
  94. <view class="cover">
  95. <image class="img" :src="item.pictureUrl"/>
  96. </view>
  97. <view class="cont">
  98. <view class="goods-name">
  99. {{item.goodsName}}
  100. </view>
  101. <view class="desc">
  102. 库存: {{item.maxNum}}, 价格: ¥{{moneyConverter(item.activityPrice)}}
  103. </view>
  104. </view>
  105. </view>
  106. </scroll-view>
  107. </view>
  108. </u-modal>
  109. <!-- <view class="sign-up">
  110. <view class="btn" @click="signUp" v-if="joinBtnVisible">报名</view>
  111. </view> -->
  112. </view>
  113. </template>
  114. <script>
  115. import {mapState} from 'vuex';
  116. export default {
  117. data () {
  118. return {
  119. getStoreSingleGoodsForStoreUrl: '/storeGoodsManageApi/getStoreSingleGoodsForStore',
  120. getStoreDineAndDashInfoForStoreUrl: '/dineAndDashActivityApi/getStoreDineAndDashInfoForStore',
  121. joinDineAndDashInfoForStoreUrl: '/dineAndDashActivityApi/joinDineAndDashInfoForStore',
  122. getJoinedActivityStoreCountForStoreUrl: '/dineAndDashActivityApi/getJoinedActivityStoreCountForStore',
  123. dineAndDashId: '',
  124. joinedActivityStoreCount: 0,
  125. form: {
  126. dineAndDashId : '',
  127. title : '',
  128. imgUrl : '',
  129. activityPrice : '',
  130. startDate : '',
  131. endDate : '',
  132. status : '',
  133. price : '',
  134. reachPrice : '',
  135. maxNum : '',
  136. storeId : '',
  137. storeName : '',
  138. goodsId : '',
  139. goodsName : '',
  140. residueNum : '',
  141. total : '',
  142. costPrice : '',
  143. salePrice : '',
  144. pictureUrl : '',
  145. },
  146. goods: {
  147. goodsId: '',
  148. goodsName: '',
  149. costPrice: '',
  150. modelId: '',
  151. pictureUrl: '',
  152. activityPrice: '',
  153. activityNum: ''
  154. },
  155. doflg: false,
  156. joinBtnVisible: false,
  157. joinActivityVisible: false,
  158. chooseGoodsVisible: false,
  159. goodsList: [],
  160. }
  161. },
  162. computed: {
  163. ...mapState(['storeInfo'])
  164. },
  165. methods: {
  166. moveHandle() {
  167. return false
  168. },
  169. signUp () {
  170. uni.showLoading({
  171. title: '加载中'
  172. });
  173. var dateStr = (new Date()).getTime();
  174. var sign = this.getSign('' + this.dineAndDashId + dateStr);
  175. this.requst({
  176. url: this.getJoinedActivityStoreCountForStoreUrl,
  177. data: {
  178. timestamp: dateStr,
  179. sign: sign,
  180. dineAndDashId: this.dineAndDashId
  181. },
  182. success: res => {
  183. if (res.data.rtnBean.rtnCode == 0) {
  184. uni.hideLoading();
  185. this.joinedActivityStoreCount = res.data.obj;
  186. if (Number(this.form.maxNum) > Number(this.joinedActivityStoreCount)) {
  187. this.joinActivityVisible = true;
  188. } else {
  189. this.$api.msg("报名商家已达到上限,请以后再参加,感谢您的配合!");
  190. }
  191. } else {
  192. uni.hideLoading();
  193. }
  194. },
  195. fail: (e) => {
  196. console.log("接口调用失败:" + JSON.stringify(e));
  197. uni.hideLoading();
  198. },
  199. })
  200. },
  201. handItem (item) {
  202. if (Number(item.activityPrice) < Number(this.form.price)) {
  203. this.$api.msg("参加活动的商品价格不能低于" + this.moneyConverter(this.form.price) + "元,请重新选择!");
  204. return;
  205. }
  206. this.goods.goodsId = item.goodsId
  207. this.goods.goodsName = item.goodsName;
  208. this.goods.costPrice = item.costPrice;
  209. this.goods.activityPrice = item.activityPrice;
  210. this.goods.modelId = item.modelId;
  211. this.goods.pictureUrl = item.pictureUrl;
  212. this.chooseGoodsVisible = false
  213. },
  214. chooseGoods() {
  215. this.goodsName = '';
  216. this.getGoodsList();
  217. this.chooseGoodsVisible = true;
  218. },
  219. getGoodsList() {
  220. uni.showLoading({
  221. title: '加载中'
  222. });
  223. var dateStr = (new Date()).getTime();
  224. var sign = this.getSign('' + this.storeInfo.storeId + dateStr);
  225. this.requst({
  226. url: this.getStoreSingleGoodsForStoreUrl,
  227. data: {
  228. timestamp: dateStr,
  229. sign: sign,
  230. storeId: this.storeInfo.storeId,
  231. goodsName: this.goodsName
  232. },
  233. success: res => {
  234. this.goodsList = res.data.list;
  235. uni.hideLoading();
  236. },
  237. fail: (e) => {
  238. console.log("接口调用失败:" + JSON.stringify(e));
  239. uni.hideLoading();
  240. },
  241. })
  242. },
  243. getData() {
  244. uni.showLoading({
  245. title: '加载中'
  246. });
  247. var dateStr = (new Date()).getTime();
  248. var sign = this.getSign('' + this.storeInfo.storeId + dateStr);
  249. this.requst({
  250. url: this.getStoreDineAndDashInfoForStoreUrl,
  251. data: {
  252. timestamp: dateStr,
  253. sign: sign,
  254. dineAndDashStoreId: this.dineAndDashId,
  255. storeId: this.storeInfo.storeId
  256. },
  257. success: res => {
  258. if (res.data.rtnBean.rtnCode == 0) {
  259. this.form = res.data.obj;
  260. if (this.form.storeId) {
  261. this.doflg = true;
  262. }
  263. if (!this.doflg && this.form.status == 0) {
  264. this.joinBtnVisible = true;
  265. } else {
  266. this.joinBtnVisible = false;
  267. }
  268. } else {
  269. this.$api.msg(res.data.rtnBean.rtnMsg);
  270. uni.navigateBack();
  271. }
  272. uni.hideLoading();
  273. },
  274. fail: (e) => {
  275. console.log("接口调用失败:" + JSON.stringify(e));
  276. uni.hideLoading();
  277. },
  278. })
  279. },
  280. joinActivity() {
  281. if (!this.goods.goodsId) {
  282. this.$api.msg("请选择参加活动的商品");
  283. return;
  284. }
  285. if (!this.goods.activityNum) {
  286. this.$api.msg("请输入参加活动的商品数量");
  287. return;
  288. }
  289. if (Number(this.goods.activityPrice * this.goods.activityNum) < Number(this.form.activityPrice)) {
  290. this.$api.msg("参加活动的商品总价值不能低于" + this.moneyConverter(this.form.activityPrice) + "元,请增加参加活动的商品数量!");
  291. return;
  292. }
  293. uni.showLoading({
  294. title: '加载中'
  295. });
  296. var dateStr = (new Date()).getTime();
  297. var sign = this.getSign('' + this.storeInfo.storeId + dateStr);
  298. this.requst({
  299. url: this.joinDineAndDashInfoForStoreUrl,
  300. data: {
  301. timestamp: dateStr,
  302. sign: sign,
  303. storeId: this.storeInfo.storeId,
  304. dineAndDashId: this.dineAndDashId,
  305. goodsId: this.goods.goodsId,
  306. total: this.goods.activityNum
  307. },
  308. success: res => {
  309. if (res.data.rtnBean.rtnCode == 0) {
  310. this.$api.msg("报名成功")
  311. this.getData();
  312. } else {
  313. this.$api.msg(res.data.rtnBean.rtnMsg);
  314. }
  315. this.joinActivityVisible = false;
  316. uni.hideLoading();
  317. },
  318. fail: (e) => {
  319. console.log("接口调用失败:" + JSON.stringify(e));
  320. uni.hideLoading();
  321. },
  322. })
  323. }
  324. },
  325. onLoad (opt) {
  326. this.dineAndDashId = opt.id;
  327. this.getData();
  328. }
  329. }
  330. </script>
  331. <style lang="scss" scoped>
  332. .overlord-meal-detail-page {
  333. width: 100vw;
  334. height: 100vh;
  335. background-color: #f5f5f5;
  336. }
  337. .scroll-content {
  338. height: calc(100vh - 120rpx - env(safe-area-inset-bottom));
  339. height: calc(100vh - 120rpx - constant(safe-area-inset-bottom));
  340. }
  341. .banner {
  342. width: 100vw;
  343. height: 212rpx;
  344. margin-bottom: 20rpx;
  345. }
  346. .item {
  347. padding: 20rpx 40rpx;
  348. box-sizing: border-box;
  349. @include flexStart;
  350. font-size: $font-base;
  351. .label {
  352. width: 200rpx;
  353. color: $desc-color;
  354. }
  355. .value {
  356. width: calc(100% - 200rpx);
  357. }
  358. }
  359. .cy-goods {
  360. height: 80rpx;
  361. padding: 0 40rpx;
  362. box-sizing: border-box;
  363. font-size: $font-base;
  364. background-color: #f5f5f5;
  365. @include flexStart;
  366. }
  367. .goods {
  368. background-color: #fff;
  369. @include flexStart;
  370. padding: 20rpx;
  371. box-sizing: border-box;
  372. .cover {
  373. width: 166rpx;
  374. height: 166rpx;
  375. border-radius: 10rpx;
  376. margin-right: 24rpx;
  377. .img {
  378. width: 166rpx;
  379. height: 166rpx;
  380. }
  381. }
  382. .cont {
  383. width: calc(100% - 200rpx);
  384. font-size: $font-base;
  385. height: 166rpx;
  386. overflow: hidden;
  387. }
  388. .name {
  389. width: 100%;
  390. text-overflow: -o-ellipsis-lastline;
  391. overflow: hidden;
  392. text-overflow: ellipsis;
  393. display: -webkit-box;
  394. -webkit-line-clamp: 2;
  395. -webkit-box-orient: vertical;
  396. }
  397. .tools {
  398. @include flexStart;
  399. }
  400. .price {
  401. margin-right: 40rpx;
  402. color: $uni-color-button;
  403. }
  404. .origin-price {
  405. color: $desc-color;
  406. }
  407. .desc {
  408. color: $desc-color;
  409. }
  410. }
  411. .sign-up {
  412. width: 100vw;
  413. position: fixed;
  414. left: 0;
  415. bottom: 0;
  416. background-color: #fff;
  417. @include flexCenter;
  418. .btn {
  419. width: 80vw;
  420. height: 80rpx;
  421. border-radius: 40rpx;
  422. background-color: $theme-color;
  423. color: #fff;
  424. @include flexCenter;
  425. margin: 20rpx 0 calc(20rpx + env(safe-area-inset-bottom));
  426. margin: 20rpx 0 calc(20rpx + constant(safe-area-inset-bottom));
  427. }
  428. }
  429. /deep/ .u-modal__content {
  430. padding: 30rpx!important;
  431. box-sizing: border-box;
  432. }
  433. .container {
  434. width: 100%;
  435. padding: 40rpx 20rpx;
  436. box-sizing: border-box;
  437. .item {
  438. width: 100%;
  439. height: 80rpx;
  440. @include between;
  441. border-bottom: 2rpx solid #f5f5f5;
  442. }
  443. .value {
  444. @include flexEnd;
  445. flex: 1;
  446. }
  447. .text {
  448. margin-left: 20rpx;
  449. }
  450. }
  451. .modal-container {
  452. width: 100%;
  453. .search-wrap {
  454. width: 100%;
  455. @include flexCenter;
  456. border: 2rpx solid $theme-color;
  457. color: $theme-color;
  458. font-size: $font-base;
  459. padding-left: 20rpx;
  460. box-sizing: border-box;
  461. margin-bottom: 20rpx;
  462. .btn {
  463. width: 128rpx;
  464. height: 60rpx;
  465. @include flexCenter;
  466. border-left: 2rpx solid $theme-color;
  467. }
  468. .input-wrap {
  469. flex: 1;
  470. /deep/ .u-input {
  471. width: 100%;
  472. }
  473. }
  474. }
  475. .goods-list {
  476. height: 500rpx;
  477. overflow-y: auto;
  478. overflow-x: hidden;
  479. .goods-item {
  480. margin-bottom: 20rpx;
  481. @include flexStart;
  482. }
  483. .cover {
  484. width: 120rpx;
  485. height: 120rpx;
  486. border-radius: 10rpx;
  487. margin-right: 20rpx;
  488. .img {
  489. width: 120rpx;
  490. height: 120rpx;
  491. }
  492. }
  493. .cont {
  494. font-size: $font-base;
  495. .goods-name {
  496. width: 100%;
  497. text-overflow: -o-ellipsis-lastline;
  498. overflow: hidden;
  499. text-overflow: ellipsis;
  500. display: -webkit-box;
  501. -webkit-line-clamp: 2;
  502. -webkit-box-orient: vertical;
  503. color: $text-color;
  504. }
  505. .desc {
  506. color: $desc-color;
  507. }
  508. }
  509. }
  510. }
  511. .footer-btn {
  512. width: 100vw;
  513. margin-top: 40rpx;
  514. @include flexCenter;
  515. .logout {
  516. width: 80%;
  517. height: 80rpx;
  518. border-radius: 40rpx;
  519. background-color: $theme-color;
  520. color: #fff;
  521. @include flexCenter;
  522. }
  523. }
  524. </style>