tool-coupon.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <div class="tool-coupon">
  3. <!--<div class="selectMode">-->
  4. <!--<div>添加优惠券</div>-->
  5. <!--<el-radio-group class="modeRight" v-model="modeValue" @change="modeChange">-->
  6. <!--<el-radio label="1">手动添加</el-radio>-->
  7. <!--<div class="mode2">-->
  8. <!--<el-radio label="2">自动获取</el-radio>-->
  9. <!--<el-tooltip class="item" effect="dark" content="系统自动获取仅设置为“公开领取”的店铺优惠券,新创建的券排在前面" placement="bottom">-->
  10. <!--<span class="iconfont">&#xe60a;</span>-->
  11. <!--</el-tooltip>-->
  12. <!--</div>-->
  13. <!--</el-radio-group>-->
  14. <!--</div>-->
  15. <div class="addCouponBox" v-show="couponBtnVisible">
  16. <div v-if="couponList && couponList.length > 0" class="couponBox">
  17. <ul>
  18. <li v-for="(item,index) in couponList" :key="index">
  19. <h4>{{item.couponName?item.couponName:item.activityName}}</h4>
  20. <a class="btn-close">
  21. <i class="icon iconfont icon-close" @click="delCoupon(index)"></i>
  22. </a>
  23. </li>
  24. </ul>
  25. </div>
  26. <div class="addCouponBtn" @click="addCoupon">
  27. <i class="iconfont">&#xe685;</i><span>添加优惠券</span>
  28. </div>
  29. </div>
  30. <el-dialog title="选择优惠券" :visible.sync="couponDialogVisible" width="1000">
  31. <coupon-select ref="couponSelect"></coupon-select>
  32. <span slot="footer" class="dialog-footer">
  33. <el-button @click="couponDialogVisible = false">取 消</el-button>
  34. <el-button type="primary" @click="couponChanged">确 定</el-button>
  35. </span>
  36. </el-dialog>
  37. </div>
  38. </template>
  39. <script>
  40. import CouponSelect from './coupon-select'
  41. import { mapGetters, mapMutations } from 'vuex'
  42. import api from '@@/components/canvasShow/config/api'
  43. import Cookies from 'js-cookie'
  44. export default {
  45. name: 'tool-coupon',
  46. components: { CouponSelect },
  47. props: {
  48. selectedCoupon: {
  49. type: Array,
  50. default: () => []
  51. },
  52. couponList: {
  53. type: Array,
  54. default: () => []
  55. }
  56. },
  57. data () {
  58. return {
  59. modeValue: '1', // 添加优惠券方式
  60. couponBtnVisible: true,
  61. couponDialogVisible: false
  62. }
  63. },
  64. computed: {
  65. ...mapGetters([
  66. 'typeId'
  67. ])
  68. },
  69. methods: {
  70. ...mapMutations({
  71. setCouponNum: 'SET_COUPONNUM'
  72. }),
  73. // 添加优惠券
  74. addCoupon () {
  75. let _this=this
  76. this.couponDialogVisible = true
  77. // this.$nextTick(function () {
  78. // _this.$refs.couponSelect.resetTableData(_this.couponList);
  79. // })
  80. },
  81. // 确定选择
  82. couponChanged () {
  83. this.couponDialogVisible = false
  84. this.couponList = this.$refs.couponSelect.multipleSelection
  85. this.couponListIds = []
  86. this.couponList.forEach(item => {
  87. if(this.typeId===1){
  88. this.couponListIds.push(item.couponId)
  89. } else if(this.typeId===3){
  90. this.couponListIds.push(item.shopCouponId)
  91. }
  92. })
  93. this.$emit('update:couponList', this.couponList)
  94. this.$emit('update:selectedCoupon', this.couponListIds)
  95. this.setCouponNum()
  96. },
  97. // 删除已选优惠券
  98. delCoupon (index) {
  99. this.couponList.splice(index,1)
  100. this.couponListIds.splice(index,1)
  101. this.$emit('update:couponList', this.couponList)
  102. this.$emit('update:selectedCoupon', this.couponListIds)
  103. this.setCouponNum()
  104. }
  105. }
  106. }
  107. </script>
  108. <style lang="scss" scoped>
  109. .tool-coupon{
  110. padding-bottom: 20px;
  111. }
  112. .selectMode {
  113. display: flex;
  114. justify-content: space-between;
  115. align-items: center;
  116. .modeRight {
  117. display: flex;
  118. .iconfont{
  119. cursor: pointer;
  120. }
  121. }
  122. ::v-deep .el-radio {
  123. margin-right: 0;
  124. }
  125. ::v-deep .el-radio__label {
  126. padding-left: 5px;
  127. }
  128. .mode2 {
  129. margin-left: 10px;
  130. span {
  131. font-size: 14px;
  132. color: #999999;
  133. }
  134. }
  135. }
  136. .addCouponBox {
  137. background: #F6F7F9;
  138. padding: 10px 13px;
  139. margin: 20px 0 0;
  140. .addCouponBtn {
  141. display: flex;
  142. justify-content: center;
  143. align-items: center;
  144. height: 40px;
  145. line-height: 40px;
  146. background: #ffffff;
  147. font-size: 14px;
  148. color: $mainColor;
  149. border: 1px solid $mainColor;
  150. box-sizing: border-box;
  151. cursor: pointer;
  152. i {
  153. margin-right: 10px;
  154. }
  155. }
  156. }
  157. .couponBox {
  158. display: flex;
  159. align-items: center;
  160. justify-content: space-between;
  161. ul{
  162. width: 100%;
  163. li{
  164. height: 40px;
  165. line-height: 40px;
  166. text-indent: 10px;
  167. position: relative;
  168. margin-bottom: 10px;
  169. width: 100%;
  170. box-shadow: 0 0 4px 0 rgb(10 42 97 / 20%);
  171. .btn-close{
  172. position: absolute;
  173. right: -8px;
  174. top: -8px;
  175. line-height: 16px;
  176. display: none;
  177. i{
  178. display: block;
  179. color: #c3c3c3;
  180. }
  181. }
  182. &:hover .btn-close{
  183. display: block;
  184. }
  185. }
  186. }
  187. }
  188. </style>