VoucherList.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <seller-base :show="false" class="scroll-view-wrapper">
  3. <view style="position: absolute;top:0;right:0;left:0;bottom:0" class="scroll-view-wrapper scroll-view div container">
  4. <view class="div common-header-wrap">
  5. <view :style="'height:'+navHeight+'px'"></view>
  6. <view class="common-header-holder"></view>
  7. <view class="common-header-fixed">
  8. <title-header />
  9. <uni-nav-bar title="代金券列表" class="common-header" left-icon="back" @clickLeft="goBack()">
  10. </uni-nav-bar>
  11. </view>
  12. </view>
  13. <view v-if="!seller.is_platform_store" class="div notice">
  14. <text class="span">套餐过期时间:<text v-if="current_quota" class="span red">{{$moment.unix(current_quota.voucherquota_endtime).format('YYYY.MM.DD')}}</text><text class="span red" v-else>您还没购买套餐</text></text>
  15. <view class="div common-btn ds-button-small btn" @click="addQuota(current_quota)"><text class="span" v-if="current_quota">续期</text><text class="span" v-else>购买</text></view>
  16. </view>
  17. <view class="scroll-view div pb-30" style="position:relative">
  18. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" class="div pb-30" @scrolltolower="loadMore" scroll-y="true">
  19. <view class="div list-wrapper" v-if="voucher_list && voucher_list.length">
  20. <view class="div voucher_list" v-for="(item,index) in voucher_list" :key="item.voucher_id" >
  21. <view class="div voucher-info">
  22. <view class="div price">{{item.vouchertemplate_price}}<text class="span">元</text></view>
  23. <view class="div info">
  24. <view class="p">订单满{{item.vouchertemplate_limit}}元</view>
  25. <view class="p">可领取总数{{item.vouchertemplate_total}}张</view>
  26. <view class="p">已领取{{item.vouchertemplate_giveout}}张</view>
  27. <view class="p">有效期至{{$moment.unix(item.vouchertemplate_enddate).format('YYYY.MM.DD')}}</view>
  28. </view>
  29. <view class="div use" @click="goVoucerEdit(item)"><text class="span" :style="(item.vouchertemplate_state == 1 && !item.vouchertemplate_giveout) ? 'opacity:1':'opacity:0'">编辑</text></view>
  30. </view>
  31. <view class="div voucher-title" >“{{item.vouchertemplate_title}}”</view>
  32. </view>
  33. </view>
  34. <empty-record v-else-if="voucher_list && !voucher_list.length"></empty-record>
  35. </scroll-view>
  36. <view class='common-add-btn-wrapper' v-if="current_quota"><view class="div common-btn common-add-btn" @click="goNavigate('/pages/seller/voucher/VoucherForm',{mode:'add'})">新增</view></view>
  37. </view>
  38. </view>
  39. <uni-popup background-color="#fff" ref="confirm" type="dialog">
  40. <uni-popup-dialog :mode="dialog.mode" :title="dialog.title" :content="dialog.content" :placeholder="dialog.content" @confirm="confirmDialog" @close="closeDialog"></uni-popup-dialog>
  41. </uni-popup>
  42. </seller-base>
  43. </template>
  44. <script>
  45. import {getFontSize} from '@/util/common'
  46. import TitleHeader from '../../TitleHeader'
  47. import { urlencode } from '@/util/common'
  48. import SellerBase from '../SellerBase'
  49. import { getVoucherList, addQuota } from '../../../api/sellerVoucher'
  50. import EmptyRecord from '../../EmptyRecord'
  51. import { mapState, mapMutations } from 'vuex'
  52. export default {
  53. name: 'BalanceHistory',
  54. components:{
  55. TitleHeader,
  56. SellerBase,
  57. EmptyRecord
  58. },
  59. data(){
  60. return {
  61. navHeight: 0,
  62. dialog:{},
  63. params: { 'page': 0, 'per_page': 10 },
  64. loading: false, // 是否加载更多
  65. isMore: true, // 是否有更多
  66. voucher_list: false,
  67. current_quota: false,
  68. voucher_storetimes_limit: false,
  69. promotion_voucher_price: false,
  70. }
  71. },
  72. onShow () {
  73. this.reload()
  74. },
  75. mounted(){
  76. // #ifdef MP-WEIXIN
  77. this.navHeight = uni.getMenuButtonBoundingClientRect().height
  78. // #endif
  79. },
  80. computed:{
  81. fontSize(){
  82. return getFontSize()
  83. },
  84. ...mapState({
  85. seller: state => state.seller.info
  86. })
  87. },
  88. methods:{
  89. closeDialog(){
  90. },
  91. confirmDialog(value){
  92. addQuota(value).then(res => {
  93. uni.showToast({icon:'none',title: res.message})
  94. this.current_quota = { voucherquota_endtime: res.result.voucherquota_endtime }
  95. }).catch(function (error) {
  96. uni.showToast({icon:'none',title: error.message})
  97. })
  98. },
  99. goNavigate(path,query=false){
  100. uni.navigateTo({url:path+(query?('?'+urlencode(query)):'')})
  101. },
  102. goBack(){uni.navigateBack({delta:1})},
  103. loadMore () {
  104. this.loading = true
  105. this.params.page = ++this.params.page
  106. if (this.isMore) {
  107. this.loading = false
  108. this.getVoucherList(true)
  109. }
  110. },
  111. reload () {
  112. // 重新加载数据
  113. this.params.page = 0
  114. this.isMore = true
  115. this.voucher_list = false
  116. this.loadMore()
  117. },
  118. goVoucerEdit (item) {
  119. if (item.vouchertemplate_state == 1 && !item.vouchertemplate_giveout) {
  120. uni.navigateTo({url:'/pages/seller/voucher/VoucherForm'+'?'+urlencode({ mode: 'edit', tid: item.vouchertemplate_id })})
  121. } else {
  122. uni.showToast({icon:'none',title: '当前代金券不可编辑'})
  123. }
  124. },
  125. addQuota (type) {
  126. this.dialog={mode:'input',title:(type ? '续期' : '购买') + '套餐',content:'购买单位为月(30天),一次最多购买12个月,每月您需要支付' + this.promotion_voucher_price + '元,相关费用会在店铺的账期结算中扣除,每月最多发布活动' + this.voucher_storetimes_limit + '次',data:type,inputType: 'number'}
  127. this.$refs.confirm.open()
  128. },
  129. getVoucherList () {
  130. uni.showLoading({ title: '加载中' })
  131. getVoucherList(this.params).then(res => {
  132. uni.hideLoading()
  133. if (res.result.hasmore) {
  134. this.isMore = true
  135. } else {
  136. this.isMore = false
  137. }
  138. this.current_quota = res.result.current_quota
  139. this.promotion_voucher_price = res.result.promotion_voucher_price
  140. this.voucher_storetimes_limit = res.result.voucher_storetimes_limit
  141. let temp = res.result.vouchertemplate_list
  142. if (temp) {
  143. if (!this.voucher_list) {
  144. this.voucher_list = temp
  145. } else {
  146. this.voucher_list = this.voucher_list.concat(temp)
  147. }
  148. }
  149. }).catch(function (error) {
  150. uni.hideLoading()
  151. uni.showToast({icon:'none',title: error.message})
  152. })
  153. }
  154. }
  155. }
  156. </script>
  157. <style scoped lang="scss">
  158. .scroll-view-wrapper{display: flex;flex-direction: column;}
  159. .scroll-view{flex:1}
  160. .container {
  161. height: 100%;
  162. display: flex;
  163. position: relative;
  164. flex-direction: column;
  165. justify-content: flex-start;
  166. align-items: stretch;
  167. }
  168. .common-voucher{margin:0.5rem auto}
  169. .notice{font-size:.7rem;padding:.5rem;background:#FCF8E3;color:#C09853;line-height: 1.6rem;
  170. .red{color:#F00}
  171. .btn{float:right}
  172. }
  173. .voucher_list{
  174. margin: .5rem;
  175. -webkit-border-radius: .75rem;
  176. border-radius: .75rem;
  177. overflow: hidden;
  178. font-size: .6rem;
  179. .voucher-info{
  180. position: relative;
  181. display: -webkit-box;
  182. display: -webkit-flex;
  183. display: flex;
  184. -webkit-box-align: center;
  185. -webkit-align-items: center;
  186. align-items: center;
  187. -webkit-box-pack: justify;
  188. -webkit-justify-content: space-between;
  189. justify-content: space-between;
  190. padding: .8rem 1rem;
  191. background: -webkit-linear-gradient(
  192. 45deg
  193. ,#ff8580,#ea5165);
  194. background: linear-gradient(
  195. 45deg
  196. ,#ff8580,#ea5165);
  197. color: #fff;
  198. border-bottom: 1px dashed #fff;
  199. .price{
  200. font-size: 1.3rem;
  201. font-weight: 700;
  202. .span{
  203. font-size: .6rem;
  204. }
  205. }
  206. .use .span{
  207. display: -webkit-box;
  208. display: -webkit-flex;
  209. display: flex;
  210. -webkit-box-align: center;
  211. -webkit-align-items: center;
  212. align-items: center;
  213. -webkit-box-pack: center;
  214. -webkit-justify-content: center;
  215. justify-content: center;
  216. padding: .25rem .5rem;
  217. background-color: #f9ccd1;
  218. font-size: .6rem;
  219. color: #ec5667;
  220. -webkit-border-radius: .2rem;
  221. border-radius: .2rem;
  222. }
  223. }
  224. .voucher-info::before,.voucher-info::after{
  225. position: absolute;
  226. content: "";
  227. bottom: -5px;
  228. width: 12px;
  229. height: 12px;
  230. -webkit-border-radius: 50%;
  231. border-radius: 50%;
  232. background-color: #fff;
  233. z-index: 2;
  234. }
  235. .voucher-info::before{
  236. right: -6px;
  237. }
  238. .voucher-info::after{
  239. left: -6px;
  240. }
  241. .voucher-title{
  242. display: -webkit-box;
  243. display: -webkit-flex;
  244. display: flex;
  245. -webkit-box-align: center;
  246. -webkit-align-items: center;
  247. align-items: center;
  248. padding: .6rem 1rem;
  249. background: -webkit-gradient(linear,left top,right top,from(#d6706b),to(#c44654));
  250. background: -webkit-linear-gradient(left,#d6706b,#c44654);
  251. background: linear-gradient(
  252. 90deg
  253. ,#d6706b,#c44654);
  254. color: #84292b;
  255. }
  256. }
  257. </style>