index.php 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240
  1. <?php defined('YII_ENV') or exit('Access Denied'); ?>
  2. <style>
  3. .set-el-button {
  4. padding: 0 !important;
  5. border: 0;
  6. margin: 0 5px;
  7. }
  8. .sort-input {
  9. width: 100%;
  10. background-color: #F3F5F6;
  11. height: 32px;
  12. }
  13. .sort-input span {
  14. height: 32px;
  15. width: 100%;
  16. line-height: 32px;
  17. display: inline-block;
  18. padding: 0 10px;
  19. font-size: 13px;
  20. }
  21. .sort-input .el-input__inner {
  22. height: 32px;
  23. line-height: 32px;
  24. background-color: #F3F5F6;
  25. float: left;
  26. padding: 0 10px;
  27. border: 0;
  28. }
  29. .table-body {
  30. padding: 20px;
  31. background-color: #fff;
  32. }
  33. .table-info .el-button {
  34. padding: 0 !important;
  35. border: 0;
  36. margin: 0 5px;
  37. }
  38. .input-item {
  39. margin: 0 0 20px;
  40. }
  41. .input-item-name {
  42. margin-right: 5px;
  43. }
  44. .input-search {
  45. margin-right: 30px;
  46. }
  47. .input-item .el-input-group__append {
  48. background-color: #fff;
  49. border-left: 0;
  50. width: 10%;
  51. padding: 0;
  52. }
  53. .input-item .el-input-group__append .el-button {
  54. padding: 0;
  55. }
  56. .input-item .el-input-group__append .el-button {
  57. margin: 0;
  58. }
  59. .data-pop-info {
  60. /* padding: 18px 15px 30px; */
  61. color: #333;
  62. }
  63. .data-pop-mode {
  64. background: #F8F8F8;
  65. border-radius: 4px;
  66. margin-bottom: 10px;
  67. }
  68. .data-pop-top {
  69. height: 90px;
  70. }
  71. .data-price {
  72. width: 200px;
  73. flex-direction: column;
  74. border-right: 1px solid #E5E5E5;
  75. }
  76. .data-info {
  77. flex: 1;
  78. padding: 22px 15px;
  79. font-size: 16px;
  80. }
  81. .data-info-name {
  82. display: inline-block;
  83. text-align: end;
  84. }
  85. .data-pop-detail {
  86. padding: 15px 18px;
  87. }
  88. .data-detail-mode {
  89. min-width: 33%;
  90. flex-shrink: 0;
  91. text-align: center;
  92. margin-top: 16px;
  93. line-height: 26px;
  94. font-size: 16px;
  95. }
  96. .share-pop-model {
  97. margin-top: 20px;
  98. }
  99. .share-name {
  100. width: 90px;
  101. display: inline-block;
  102. margin-right: 18px;
  103. text-align: end;
  104. }
  105. .flex-y-center {
  106. display: -webkit-box;
  107. display: -webkit-flex;
  108. display: flex;
  109. -webkit-box-align: center;
  110. -webkit-align-items: center;
  111. -ms-flex-align: center;
  112. -ms-grid-row-align: center;
  113. align-items: center;
  114. }
  115. </style>
  116. <div id="app" v-cloak>
  117. <el-card shadow="never" style="border:0" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  118. <div slot="header">
  119. <span>优惠券管理</span>
  120. <el-button style="float: right; margin-top: -8px;" type="primary" size="small" @click="$navigate({r:'coupon/default/edit'})">新建优惠券
  121. </el-button>
  122. </div>
  123. <div class="table-body">
  124. <div id="qrcode-info" style="position: fixed;top: 10000000000px;">
  125. <!-- 背景图 -->
  126. <el-image id="couponBak" style="width: 144px; height: 144px;" src="/resources/img/plugins/coupon/coupon_bak.png"></el-image>
  127. <!-- 头像 -->
  128. <el-image id="topImg" style="width: 144px; height: 144px;" v-if="mall_info" :src="mall_info.mall_logo"></el-image>
  129. <!-- 二维码 -->
  130. <!-- <el-image id="codeImg" style="width: 95px; height: 95px;" src="/resources/img/plugins/coupon/code.png"></el-image> -->
  131. <div id="qrcode" style="width:100px; height:100px; margin-top:15px;"></div>
  132. <div id="mini_qrcode" style="width:100px; height:100px; margin-top:15px;"></div>
  133. <!-- 生成的海报图片 -->
  134. <el-image id="posterImg" style="width: 375px; height: 603px;" :src="this.shareData.poster"></el-image>
  135. <!-- 生成海报 -->
  136. <canvas id="myCanvas" width="375" height="603" style="border:1px solid #d3d3d3;"></canvas>
  137. </div>
  138. <div class="input-item">
  139. <div flex>
  140. <div flex="cross:center" class="input-search">
  141. <div class="input-item-name">优惠券名称:</div>
  142. <div class="input-item-text">
  143. <el-input @keyup.enter.native="search" size="small" placeholder="请输入优惠券名称搜索" v-model="searchData.name" clearable @clear="search"></el-input>
  144. </div>
  145. </div>
  146. <div flex="cross:center" class="input-search">
  147. <div class="input-item-name">类型:</div>
  148. <div>
  149. <el-select v-model="searchData.type" placeholder="请选择" size="small">
  150. <el-option label="全部" :value="0"></el-option>
  151. <el-option v-for="(item,index) in type_text" :key="index" :label="item" :value="index">{{item}}
  152. </el-option>
  153. </el-select>
  154. </div>
  155. </div>
  156. <div flex="cross:center" class="input-search">
  157. <div class="input-item-name">状态:</div>
  158. <div>
  159. <el-select v-model="searchData.status" placeholder="请选择" size="small">
  160. <el-option label="全部" :value="0"></el-option>
  161. <el-option v-for="(item,index) in status_text" :key="index" :label="item" :value="index">{{item}}
  162. </el-option>
  163. </el-select>
  164. </div>
  165. </div>
  166. <div style="margin-left: 90px;margin-top: 0px;">
  167. <el-button type="primary" size="small" @click="search">搜索</el-button>
  168. <el-button type="warning" @click="clereSearch" v-if="searchData.name || searchData.type || searchData.status" style="padding: 9px 15px !important;">清除搜索条件</el-button>
  169. </div>
  170. </div>
  171. </div>
  172. <el-table v-loading="loading" stripe :data="list" style="width: 100%;margin-bottom: 15px">
  173. <el-table-column width='250' prop="name" label="优惠券名称" align="center"></el-table-column>
  174. <el-table-column width='150' prop="type" label="优惠券类型">
  175. <template slot-scope="scope">
  176. <div>
  177. {{type_text[scope.row.type] ?? '未知优惠券类型'}}
  178. </div>
  179. </template>
  180. </el-table-column>
  181. <el-table-column width='250' prop="discount" label="优惠内容">
  182. <template slot-scope="scope">
  183. <div>{{scope.row.content}}</div>
  184. </template>
  185. </el-table-column>
  186. <el-table-column width='150' prop="received_number" label="已领取" align="center">
  187. <template slot-scope="scope">
  188. <div v-if="scope.row.received_number">
  189. <el-button type="text" @click="couponDetail(1, scope.row.id)">{{scope.row.received_number}}</el-button>
  190. </div>
  191. <div v-else>{{scope.row.received_number}}</div>
  192. </template>
  193. </el-table-column>
  194. <el-table-column width='150' prop="used_number" label="已使用" align="center">
  195. <template slot-scope="scope">
  196. <div v-if="scope.row.used_number">
  197. <el-button @click="couponDetail(2, scope.row.id)" type="text">{{scope.row.used_number}}</el-button>
  198. </div>
  199. <div v-else>{{scope.row.used_number}}</div>
  200. </template>
  201. </el-table-column>
  202. <el-table-column prop="total_count" label="剩余数量" align="center" width="150">
  203. <template slot-scope="scope">
  204. <div v-if="total_count_id != scope.row.id">
  205. <el-tooltip class="item" effect="dark" content="剩余数量" placement="top">
  206. <span>{{scope.row.total_count}}</span>
  207. </el-tooltip>
  208. <el-button class="edit-sort" type="text" @click="edit(scope.row,'total_count')" v-if="scope.row.status == 1 && (scope.row.coupon_status == 1 || scope.row.coupon_status == 2)">
  209. <img src="resources/img/mall/order/edit.png" alt="">
  210. </el-button>
  211. </div>
  212. <div style="display: flex;align-items: center" v-else>
  213. <el-input style="min-width: 70px" type="number" size="mini" class="change" v-model="total_count" autocomplete="off"></el-input>
  214. <el-button class="change-quit" type="text" style="color: #F56C6C;padding: 0 5px" icon="el-icon-error" circle @click="cancelEdit('total_count')"></el-button>
  215. <el-button class="change-success" type="text" style="margin-left: 0;color: #67C23A;padding: 0 5px" icon="el-icon-success" circle @click="handle('total_count',scope.row)">
  216. </el-button>
  217. </div>
  218. </template>
  219. </el-table-column>
  220. <el-table-column prop="store" label="门店专用" align="center">
  221. <template slot-scope="scope" v-if="scope.row.store_id!=''||scope.row.store_id!=0">
  222. <el-button type="text" @click="showStore(scope.row)">门店列表</el-button>
  223. </template>
  224. </el-table-column>
  225. <el-table-column prop="store" label="商户专用" align="center">
  226. <template slot-scope="scope" v-if="scope.row.mch_id!=''||scope.row.mch_id!=0">
  227. <el-button type="text" @click="showMch(scope.row)">商户列表</el-button>
  228. </template>
  229. </el-table-column>
  230. <el-table-column width='150' prop="is_failure" label="状态" align="center">
  231. <template slot-scope="scope">
  232. <span v-if="scope.row.status == 0 && scope.row.total_count > 0"> 已禁用 </span>
  233. <span v-if="scope.row.status == 0 && scope.row.total_count == 0"> 已领完 </span>
  234. <span v-if="scope.row.status == 1"> {{status_text[scope.row.coupon_status]}} </span>
  235. </template>
  236. </el-table-column>
  237. <el-table-column label="操作" width="290" align="center">
  238. <template slot-scope="scope">
  239. <el-button v-if="scope.row.coupon_status != 1" type="text" @click="openPop(scope.$index,1)">数据</el-button>
  240. <el-button v-if="scope.row.coupon_status==1 || scope.row.coupon_status==2" type="text" @click="openPop(scope.$index,2)">推广码</el-button>
  241. <el-button v-if="(scope.row.coupon_status==1 || scope.row.coupon_status==2) && scope.row.is_received == false" type="text" @click="openPop(scope.$index,3)">编辑</el-button>
  242. <el-button v-if="scope.row.coupon_status==3 || scope.row.coupon_status==4" type="text" @click="openPop(scope.$index,7)">查看</el-button>
  243. <el-button v-if="scope.row.coupon_status==1 || scope.row.coupon_status==2" type="text" @click="openPop(scope.$index,4)">关闭</el-button>
  244. <el-button v-if="scope.row.status == 1 && (scope.row.coupon_status==3 || scope.row.coupon_status==4)" type="text" @click="openPop(scope.$index,5)">删除</el-button>
  245. <el-button type="text" @click="openPop(scope.$index,6)">复制</el-button>
  246. <!-- <el-button class="set-el-button" size="mini" type="text" circle
  247. @click="handleSend(scope.$index, scope.row,list.id)" v-if="scope.row.is_failure == 0">
  248. <el-tooltip class="item" effect="dark" content="发放优惠券" placement="top">
  249. <img src="statics/img/mall/send.png" alt="">
  250. </el-tooltip>
  251. </el-button>
  252. <el-button class="set-el-button" size="mini" type="text" circle
  253. @click="handleEdit(scope.$index, scope.row,list.id)">
  254. <el-tooltip class="item" effect="dark" content="编辑" placement="top">
  255. <img src="statics/img/mall/edit.png" alt="">
  256. </el-tooltip>
  257. </el-button>
  258. <el-button class="set-el-button" size="mini" type="text" circle
  259. @click="handleDel(scope.$index, scope.row,list.id)">
  260. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  261. <img src="statics/img/mall/del.png" alt="">
  262. </el-tooltip>
  263. </el-button> -->
  264. </template>
  265. </el-table-column>
  266. </el-table>
  267. <div flex="box:last cross:center">
  268. <div style="visibility: hidden">
  269. <el-button plain type="primary" size="small">批量操作1</el-button>
  270. <el-button plain type="primary" size="small">批量操作2</el-button>
  271. </div>
  272. <el-col :span="24" class="toolbar">
  273. <el-pagination v-if="pagination" style="float: right;" background @current-change="pageChange" layout="prev, pager, next" :page-count="pageCount">
  274. </el-pagination>
  275. </el-col>
  276. </div>
  277. </div>
  278. <el-dialog title="效果数据" :visible.sync="dataPop" width="40%">
  279. <div class="data-pop-info" v-loading="dataPopLoading">
  280. <div class="data-pop-top data-pop-mode" flex>
  281. <div class="data-price" flex="cross:center main:center">
  282. <div v-if="coupon_info.type==2">
  283. <span style="font-size: 14px;">¥</span>
  284. <span style="font-size: 20px;">{{coupon_info.sub_price}}</span>
  285. </div>
  286. <div v-if="coupon_info.type==1">
  287. <span style="font-size: 14px;"></span>
  288. <span style="font-size: 20px;">{{coupon_info.discount}}折</span>
  289. </div>
  290. <div style="margin-top: 5px;font-size: 16px;color: #636363;">{{coupon_info.content}}</div>
  291. </div>
  292. <div class="data-info">
  293. <div flex>
  294. <div class="data-info-name">券名称:</div>
  295. <div style="color: #4098F4;">{{coupon_info.name}}</div>
  296. </div>
  297. <div style="color: #636363;margin-top: 10px;">
  298. <span class="data-info-name">使用时间:</span>
  299. <span v-if="coupon_info.expire_type==2">{{coupon_info.use_time}}</span>
  300. <span v-else-if="coupon_info.expire_type==1">领取后{{coupon_info.expire_day}}天过期</span>
  301. <span v-else-if="coupon_info.expire_type==3">领取后{{coupon_info.effect_days}}天生效,有效期{{coupon_info.expire_day}}天</span>
  302. </div>
  303. </div>
  304. </div>
  305. <div class="data-pop-mode data-pop-detail" flex="wrap:wrap">
  306. <div class="data-detail-mode">
  307. <div class="data-detail-name">用券金额</div>
  308. <div class="data-detail-num">{{user_coupons.total_payed_amount}}</div>
  309. </div>
  310. <div class="data-detail-mode">
  311. <div class="data-detail-name">优惠总金额</div>
  312. <div class="data-detail-num">{{user_coupons.total_discount_amount}}</div>
  313. </div>
  314. <div class="data-detail-mode">
  315. <div class="data-detail-name">使用率</div>
  316. <div class="data-detail-num">{{user_coupons.use_probability}}</div>
  317. </div>
  318. <div class="data-detail-mode">
  319. <div class="data-detail-name">用券会员数</div>
  320. <div class="data-detail-num">{{user_coupons.use_user_number}}</div>
  321. </div>
  322. <div class="data-detail-mode">
  323. <div class="data-detail-name">支付订单数</div>
  324. <div class="data-detail-num">{{user_coupons.use_order_number}}</div>
  325. </div>
  326. <div class="data-detail-mode">
  327. <div class="data-detail-name">支付金额</div>
  328. <div class="data-detail-num">{{user_coupons.total_use_coupon_payed_amount}}</div>
  329. </div>
  330. </div>
  331. <div>
  332. <div style="margin-bottom: 16px;">使用优惠券购买商品</div>
  333. <el-table :data="good_statistics" style="width: 100%" stripe>
  334. <el-table-column prop="good" label="商品" align="center">
  335. <template slot-scope="scope">
  336. <div size="small" class="flex-y-center">
  337. <com-image width='50px' height='50px' :src=scope.row.cover_pic style="border-radius: 50%"></com-image>
  338. <span style="padding-left: 10px;">{{scope.row.goods_name}}</span>
  339. </div>
  340. </template>
  341. </el-table-column>
  342. <el-table-column prop="payed_number" label="付款件数" align="center"></el-table-column>
  343. <el-table-column prop="buyed_user_number" label="付款人数" align="center"></el-table-column>
  344. </el-table>
  345. </div>
  346. <div style="padding: 14px 0;">
  347. <el-pagination v-if="dataPopPagination" :page-size="dataPopPagination.pageSize" style="float: right;" background @current-change="pageChangeDataPop" layout="prev, pager, next" :total="dataPopPagination.totalCount">
  348. </el-pagination>
  349. </div>
  350. </div>
  351. </el-dialog>
  352. <el-dialog v-loading="posterLoading" element-loading-text="生成海报中" title="分享" :visible.sync="sharePop" width="30%">
  353. <el-tabs :tab-position="tabPosition">
  354. <el-tab-pane label="H5" class="flex-x-centet">
  355. <div class="share-pop-model">
  356. <div class="share-name">分享链接</div>
  357. <el-input style="width: 50%;" v-model="shareData.url" placeholder="暂无链接" disabled>
  358. <template slot="append">
  359. <el-button circle size="mini" type="text" @click="copyLink(shareData.url)" class="copy_btn">复制</el-button>
  360. </template>
  361. </el-input>
  362. </div>
  363. <div class="share-pop-model" flex>
  364. <div class="share-name">二维码</div>
  365. <div style="width: 180px; height: 180px;background: #F2F2F2;margin-right: 12px;" flex="main:center cross:center">
  366. <el-image style="width: 144px; height: 144px;" :src="shareData.img"></el-image>
  367. </div>
  368. <!-- downloadShareImg('poster') -->
  369. <el-button flex type="text" @click="getPoster">下载海报</el-button>
  370. <el-button flex type="text" @click="downloadShareImg('qrcode')">下载二维码</el-button>
  371. </div>
  372. </el-tab-pane>
  373. <el-tab-pane label="微信小程序" class="flex-x-centet">
  374. <!-- <div style="width: 180px; height: 180px;background: #F2F2F2;margin-right: 12px;" flex="main:center cross:center">-->
  375. <!-- <el-image id="code-img" style="width: 144px; height: 144px;" :src="applet_code"></el-image>-->
  376. <!-- </div>-->
  377. <!-- <el-button flex type="text" @click="downloadShareImg('mini_qrcode')">下载二维码</el-button>-->
  378. <div class="tips-text" style="line-height: 24px;color: red;padding-left: 45px">
  379. 建议新增优惠券后5分钟后进行海报操作
  380. </div>
  381. <div class="share-pop-model" flex>
  382. <div class="share-name">二维码</div>
  383. <div style="width: 180px; height: 180px;background: #F2F2F2;margin-right: 12px;" flex="main:center cross:center">
  384. <el-image style="width: 144px; height: 144px;" :src="applet_code"></el-image>
  385. </div>
  386. <!-- downloadShareImg('poster') -->
  387. <el-button flex type="text" @click="getMiniPoster">下载海报</el-button>
  388. <el-button flex type="text" @click="downloadShareImg('mini_qrcode')">下载二维码</el-button>
  389. </div>
  390. </el-tab-pane>
  391. </el-dialog>
  392. <el-dialog v-loading="posterLoading" element-loading-text="门店列表" :title="couponName" :visible.sync="store_list_show" width="30%">
  393. <el-table :data="storeList" style="width: 100%">
  394. <el-table-column prop="store_name" label="店名" width="180"></el-table-column>
  395. <el-table-column prop="shop_owner" label="店长"></el-table-column>
  396. <el-table-column prop="shop_mobile" label="手机" width="180"></el-table-column>
  397. </el-table>
  398. </el-dialog>
  399. <el-dialog v-loading="posterLoading" element-loading-text="商户列表" :title="couponName" :visible.sync="mch_list_show" width="30%">
  400. <el-table :data="mchList" style="width: 100%">
  401. <el-table-column prop="store_name" label="商户名" width="180"></el-table-column>
  402. <el-table-column prop="shop_owner" label="商户主"></el-table-column>
  403. <el-table-column prop="shop_mobile" label="手机" width="180"></el-table-column>
  404. </el-table>
  405. </el-dialog>
  406. </el-card>
  407. </div>
  408. <!-- <script src="https://cdn.jsdelivr.net/clipboard.js/1.5.12/clipboard.min.js"></script> -->
  409. <script src="/resources/unpkg/clipboard@1.5.12/dist/clipboard.min.js"></script>
  410. <script>
  411. const app = new Vue({
  412. el: '#app',
  413. data() {
  414. return {
  415. loading: false,
  416. list: [],
  417. searchData: {
  418. name: '',
  419. type: 0,
  420. status: 0,
  421. },
  422. pagination: null,
  423. dataPopPagination: null,
  424. page: 1,
  425. status_text: {
  426. 1: '未开始',
  427. 2: '领取中',
  428. 3: '已过期',
  429. 4: '已关闭'
  430. },
  431. type_text: {
  432. 1: '折扣券',
  433. 2: '满减券',
  434. 4: '兑换券'
  435. },
  436. dataPop: false, //数据弹窗
  437. dataPopLoading: false,
  438. user_coupons: {
  439. total_payed_amount: 0,
  440. total_discount_amount: 0,
  441. use_probability: 0,
  442. receive_user_number: 0,
  443. use_order_number: 0,
  444. total_use_coupon_payed_amount: 0,
  445. use_user_number: 0,
  446. },
  447. coupon_info: {
  448. name: '优惠券',
  449. content: '满100减10元',
  450. use_time: '--',
  451. },
  452. sharePop: false, //分享弹窗
  453. shareData: {
  454. url: "", //链接
  455. img: "", //二维码
  456. poster: '', // 海报图片
  457. poster_filename: '', // 海报图片文件名
  458. qrcode_filename: '', // 二维码文件名
  459. },
  460. good_statistics: [],
  461. list_index: 0, // 当前选中的列表索引,用于弹窗
  462. posterLoading: false,
  463. posterArr: {}, //生成的海报列表
  464. posterSrc: "",
  465. mall_info: {},
  466. pageSize: 10,
  467. pageCount: 1,
  468. store_list_show: false, //门店列表弹窗
  469. mch_list_show: false, //商户列表弹窗
  470. storeList: [],
  471. mchList: [],
  472. couponName:'',
  473. total_count: 0,
  474. total_count_id: 0,
  475. applet_code:"",
  476. tabPosition:'left',
  477. };
  478. },
  479. created() {
  480. this.loadData();
  481. },
  482. methods: {
  483. //搜索
  484. search() {
  485. this.page = 1;
  486. this.loadData();
  487. },
  488. clereSearch() {
  489. this.searchData.name = '';
  490. this.searchData.type = 0;
  491. this.searchData.status = 0;
  492. this.search();
  493. },
  494. handleCenter: function(row, column) {
  495. let para = Object.assign({
  496. id: column.id
  497. }, {
  498. is_join: column.is_join
  499. });
  500. request({
  501. params: {
  502. r: 'mall/coupon/edit-center'
  503. },
  504. data: para,
  505. method: 'post'
  506. }).then(e => {
  507. if (e.data.code === 0) {
  508. this.$message({
  509. message: e.data.msg,
  510. type: 'success'
  511. });
  512. } else {
  513. this.$alert(e.data.msg, '提示', {
  514. confirmButtonText: '确定'
  515. })
  516. }
  517. }).catch(e => {});
  518. },
  519. //带着ID前往编辑页面
  520. handleEdit: function(row, column) {
  521. navigateTo({
  522. r: 'mall/coupon/edit',
  523. id: column.id
  524. });
  525. },
  526. // 优惠券发放页面
  527. handleSend: function(row, column) {
  528. navigateTo({
  529. r: 'mall/coupon/send',
  530. id: column.id
  531. });
  532. },
  533. //分页
  534. pageChange(page) {
  535. this.page = page;
  536. this.loadData();
  537. },
  538. pageChangeDataPop(page) {
  539. this.dataPopPage = page;
  540. this.openPop(this.list_index, 1);
  541. },
  542. //删除
  543. handleDel: function(row, column) {
  544. this.$confirm('确认删除该记录吗?', '提示', {
  545. type: 'warning'
  546. }).then(() => {
  547. this.loading = true;
  548. let para = {
  549. id: column.id
  550. };
  551. request({
  552. params: {
  553. r: 'mall/coupon/destroy'
  554. },
  555. data: para,
  556. method: 'post'
  557. }).then(e => {
  558. this.loading = false;
  559. if (e.data.code === 0) {
  560. const h = this.$createElement;
  561. this.$message({
  562. message: '删除成功',
  563. type: 'success'
  564. });
  565. setTimeout(() => {
  566. this.loadData()
  567. }, 300);
  568. } else {
  569. this.$alert(e.data.msg, '提示', {
  570. confirmButtonText: '确定'
  571. })
  572. }
  573. }).catch(e => {
  574. this.$alert(e.data.msg, '提示', {
  575. confirmButtonText: '确定'
  576. })
  577. });
  578. })
  579. },
  580. // 根据参数获取请求信息
  581. loadData() {
  582. this.loading = true;
  583. request({
  584. params: {
  585. r: 'coupon/default/index',
  586. page: this.page,
  587. page_size: this.pageSize,
  588. name: this.searchData.name,
  589. type: this.searchData.type,
  590. status: this.searchData.status,
  591. },
  592. }).then(e => {
  593. this.loading = false;
  594. if (e.data.code === 0) {
  595. this.list = e.data.data.list;
  596. this.mall_info = e.data.data.mall_info;
  597. this.pagination = e.data.data.pagination;
  598. this.pageSize = e.data.data.pageSize;
  599. this.pageCount = e.data.data.page_count;
  600. // console.log(this.pagination.totalCount);
  601. } else {
  602. this.listLoading = false;
  603. this.$message({
  604. message: e.data.msg,
  605. type: 'error'
  606. });
  607. }
  608. }).catch(e => {
  609. this.listLoading = false;
  610. });
  611. },
  612. // 打开数据弹窗
  613. async openPop(index, type) {
  614. // console.info(index,type);
  615. this.list_index = index;
  616. if (type == 1) { //查看数据
  617. let self = this
  618. self.dataPop = true;
  619. self.dataPopLoading = true;
  620. request({
  621. params: {
  622. r: 'coupon/coupon/coupon-statistics',
  623. coupon_id: this.list[index].id,
  624. page: this.dataPopPage
  625. },
  626. method: 'get'
  627. }).then(e => {
  628. this.dataPopLoading = false;
  629. if (e.data.code == 0) {
  630. if (e.data.data.user_coupons) {
  631. self.user_coupons = e.data.data.user_coupons;
  632. }
  633. if (e.data.data.good_statistics.length) {
  634. self.good_statistics = e.data.data.good_statistics;
  635. } else {
  636. self.good_statistics = [];
  637. }
  638. if (e.data.data.coupon_info) {
  639. self.coupon_info = e.data.data.coupon_info;
  640. }
  641. self.dataPopPagination = e.data.data.good_statistics.pagination;
  642. } else {
  643. self.$message.error(e.data.msg);
  644. }
  645. }).catch(e => {
  646. this.dataPopLoading = false;
  647. console.log(e);
  648. this.$message.error('网络错误');
  649. });
  650. } else if (type == 2) { //推广
  651. let codeImgSrc = await this.getQrCode(this.list[index].page_link);
  652. this.shareData.img = codeImgSrc;
  653. this.shareData.url = this.list[index].page_link;
  654. // this.shareData.poster = this.list[index].poster_url;
  655. this.shareData.poster_filename = this.list[index].poster_filename;
  656. this.shareData.qrcode_filename = this.list[index].qrcode_filename;
  657. if(this.list[index].applet_code == ''){
  658. let store_id = 0;
  659. if(this.list[index].store_id){
  660. store_id = 1;
  661. }
  662. request({
  663. params: {
  664. r: 'coupon/coupon/show-mini-promotion-code',
  665. },
  666. method: 'post',
  667. data: {
  668. id: this.list[index].id,
  669. store_id: store_id
  670. },
  671. }).then(e => {
  672. if (e.data.code == 0) {
  673. this.applet_code = e.data.data.applet_url;
  674. } else {
  675. }
  676. }).catch(e => {
  677. console.log(e);
  678. });
  679. } else {
  680. this.applet_code = this.list[index].applet_code;
  681. }
  682. // this.applet_code = this.convertUrlToBase64(this.applet_code);
  683. this.applet_code = await this.convertUrlToBase64(this.applet_code);
  684. // this.applet_code = this.imageBase64;
  685. // console.log('this.applet_code', this.applet_code);
  686. if (this.applet_code) {
  687. let qrcodeInfo = document.getElementById("qrcode-info");
  688. document.getElementById("mini_qrcode").remove(); //删除生成的二维码
  689. let addCodeDom = document.createElement("div")
  690. addCodeDom.setAttribute("id", "mini_qrcode");
  691. addCodeDom.setAttribute("style", "width:300px; height:300px;");
  692. qrcodeInfo.appendChild(addCodeDom) //添加标签
  693. let qrMiniCodeDom = document.getElementById("mini_qrcode")
  694. var qrcode = new QRCode(qrMiniCodeDom, {
  695. width: 300,
  696. height: 300
  697. });
  698. let src = "";
  699. src = qrMiniCodeDom.getElementsByTagName("img")[0].src;
  700. const imgElement = qrMiniCodeDom.getElementsByTagName("img")[0];
  701. if (imgElement) {
  702. imgElement.src = this.applet_code;
  703. }
  704. }
  705. this.sharePop = true;
  706. } else if (type == 3) { //编辑
  707. navigateTo({
  708. r: 'coupon/default/edit',
  709. coupon_id: this.list[index].id
  710. });
  711. } else if (type == 4) { //关闭
  712. this.$confirm('活动关闭后,无法继续编辑优惠券内容;买家无法再领取该优惠券,但之前已领取的优惠券,在有效期内仍可继续使用。', '关闭', {
  713. confirmButtonText: '确定',
  714. cancelButtonText: '取消',
  715. }).then(() => {
  716. this.listLoading = true;
  717. request({
  718. params: {
  719. r: 'coupon/coupon/failure',
  720. coupon_id: this.list[index].id,
  721. },
  722. method: 'get'
  723. }).then(e => {
  724. this.listLoading = false;
  725. if (e.data.code == 0) {
  726. this.$message.success(e.data.msg);
  727. this.list[index].coupon_status = 4;
  728. } else {
  729. this.$message.error(e.data.msg);
  730. }
  731. }).catch(e => {
  732. this.listLoading = false;
  733. console.log(e);
  734. this.$message.error('网络错误');
  735. });
  736. }).catch(() => { //点击取消
  737. });
  738. } else if (type == 5) { //删除
  739. // 删除优惠之前需要判断是否有正在使用的优惠券
  740. request({
  741. params: {
  742. r: 'coupon/default/is-coupon',
  743. id: this.list[index].id
  744. },
  745. method: 'get'
  746. }).then((e) => {
  747. if (e.data.code == 0) {
  748. if (e.data.data.count > 0) {
  749. this.$confirm('当前优惠券活动,仍然存在正常使用的优惠券,如若要删除该活动 请先将所有已领取的优惠券操作失效!', '警告', {
  750. confirmButtonText: '确定',
  751. cancelButtonText: '取消',
  752. type: 'warning'
  753. }).then(() => {
  754. }).catch(() => { //点击取消
  755. });
  756. return false;
  757. }
  758. // 如果条件满足就删除优惠券
  759. this.$confirm('删除后将不可恢复,确定删除?', '删除', {
  760. confirmButtonText: '确定',
  761. cancelButtonText: '取消',
  762. }).then(() => {
  763. let self = this;
  764. self.loading = true;
  765. request({
  766. params: {
  767. r: 'coupon/coupon/delete',
  768. },
  769. data: {
  770. coupon_id: self.list[index].id
  771. },
  772. method: 'post'
  773. }).then(e => {
  774. this.loading = false;
  775. if (e.data.code == 0) {
  776. self.$message.success(e.data.msg);
  777. self.list.splice(index, 1);
  778. } else {
  779. self.$message.error(e.data.msg)
  780. }
  781. }).catch(e => {
  782. this.loading = false;
  783. console.log(e);
  784. this.$message.error('网络错误');
  785. });
  786. }).catch(() => { //点击取消
  787. });
  788. } else {
  789. this.$message.error(e.data.msg);
  790. }
  791. })
  792. } else if (type == 6) { // 复制
  793. navigateTo({
  794. r: 'coupon/default/edit',
  795. coupon_id: this.list[index].id,
  796. is_copy: true,
  797. });
  798. } else if (type == 7) { // 查看
  799. navigateTo({
  800. r: 'coupon/default/edit',
  801. coupon_id: this.list[index].id,
  802. status: this.list[index].status_int
  803. });
  804. }
  805. },
  806. // 图片下载
  807. downloadShareImg(type) {
  808. // console.log(this.shareData);return null;
  809. if ('qrcode' == type) {
  810. if (!this.shareData.img) {
  811. this.$message.error('暂无图片');
  812. return;
  813. }
  814. var img_url = this.shareData.img;
  815. var filename = this.shareData.qrcode_filename;
  816. } else if('mini_qrcode' == type) {
  817. img_url = this.applet_code;
  818. } else {
  819. if (!this.shareData.poster) {
  820. this.$message.error('暂无图片');
  821. return;
  822. }
  823. var img_url = this.shareData.poster;
  824. var filename = this.shareData.poster_filename;
  825. }
  826. fetch(img_url).then(res => res.blob().then(blob => {
  827. var a = document.createElement('a');
  828. var url = window.URL.createObjectURL(blob);
  829. a.href = url;
  830. a.download = filename;
  831. a.click();
  832. window.URL.revokeObjectURL(url);
  833. }))
  834. },
  835. copyLink(str) {
  836. var clipboard = new Clipboard('.copy_btn', {
  837. text: function() {
  838. return str;
  839. }
  840. });
  841. var self = this;
  842. clipboard.on('success', function(e) {
  843. // console.log("success")
  844. self.$message.success('复制成功');
  845. e.clearSelection();
  846. clipboard.destroy()
  847. });
  848. clipboard.on('error', function(e) {
  849. // console.log("error")
  850. self.$message.error('复制失败,请手动复制');
  851. });
  852. },
  853. // 跳转 已使用/已领取页面
  854. couponDetail(status, coupon_id) {
  855. let url = 'coupon/user-coupon/user-coupon-detail';
  856. navigateTo({
  857. r: url,
  858. status: status,
  859. coupon_id: coupon_id,
  860. });
  861. },
  862. // 生成二维码
  863. getQrCode(url) {
  864. let qrcodeInfo = document.getElementById("qrcode-info");
  865. document.getElementById("qrcode").remove(); //删除生成的二维码
  866. let addCodeDom = document.createElement("div")
  867. addCodeDom.setAttribute("id", "qrcode");
  868. addCodeDom.setAttribute("style", "width:300px; height:300px;");
  869. qrcodeInfo.appendChild(addCodeDom) //添加标签
  870. let qrCodeDom = document.getElementById("qrcode")
  871. var qrcode = new QRCode(qrCodeDom, {
  872. width: 300,
  873. height: 300
  874. });
  875. qrcode.makeCode(url);
  876. // 获取二维码生成的图片信息
  877. let src = "";
  878. return new Promise((req, rej) => {
  879. setTimeout(() => {
  880. src = qrCodeDom.getElementsByTagName("img")[0].src;
  881. req(src)
  882. }, 200);
  883. })
  884. },
  885. // 生成海报
  886. getPoster() {
  887. try {
  888. // 存在海报则不重新生成
  889. if (this.posterArr[this.list_index]) {
  890. this.shareData.poster = this.posterArr[this.list_index];
  891. return;
  892. }
  893. this.posterLoading = true;
  894. let qrcodeInfo = document.getElementById("qrcode-info");
  895. var c = document.getElementById("myCanvas");
  896. // 清空上一个生成的海报
  897. c.remove();
  898. // 创建标签
  899. let addPosterDom = document.createElement("canvas")
  900. addPosterDom.setAttribute("id", "myCanvas");
  901. addPosterDom.setAttribute("width", "375");
  902. addPosterDom.setAttribute("height", "603");
  903. qrcodeInfo.appendChild(addPosterDom);
  904. c = document.getElementById("myCanvas");
  905. var ctx = c.getContext("2d");
  906. // 背景图
  907. let bak = document.getElementById("couponBak");
  908. ctx.drawImage(bak, 0, 0, 375, 603);
  909. // 圆
  910. ctx.beginPath();
  911. ctx.arc(187.5, 105, 40, 0, 2 * Math.PI);
  912. ctx.closePath();
  913. ctx.fillStyle = "#FFF";
  914. ctx.fill(); //填充颜色
  915. let mall_header_data = JSON.parse(localStorage.getItem("mall_header_data"));
  916. // 店名
  917. ctx.font = "bold 17px Arial";
  918. ctx.fillStyle = "#000";
  919. ctx.textAlign = 'center';
  920. ctx.fillText(this.mall_info.mall_name, 187.5, 175);
  921. // 优惠券类型
  922. ctx.font = "bold 14px Arial";
  923. ctx.fillStyle = "#000";
  924. ctx.textAlign = 'center';
  925. ctx.fillText("送你一张优惠券", 187.5, 205);
  926. // 额度
  927. ctx.font = "bold 22px Arial";
  928. ctx.fillStyle = "#DB0505";
  929. ctx.textAlign = 'center';
  930. // ctx.fillText(this.list[this.list_index].content,187.5,265);
  931. ctx.fillText(this.list[this.list_index].name, 187.5, 265);
  932. let type = this.list[this.list_index].appoint_type;
  933. let typeStr = "全场可用";
  934. if (type == 1) {
  935. typeStr = "指定商品分类可用";
  936. } else if (type == 2) {
  937. typeStr = "指定商品可用";
  938. }
  939. // 可使用的类型
  940. ctx.font = "14px Arial";
  941. ctx.fillStyle = "#DB0505";
  942. ctx.textAlign = 'center';
  943. // ctx.fillText("全部商品任意金额可用",187.5,295);
  944. ctx.fillText(typeStr, 187.5, 295);
  945. // 二维码
  946. let code = document.getElementById("qrcode").getElementsByTagName("img")[0];
  947. ctx.drawImage(code, 140, 380.5, 95, 95);
  948. // 商城头像
  949. ctx.beginPath();
  950. ctx.arc(187.25, 104.75, 36.25, 0, 2 * Math.PI);
  951. ctx.clip();
  952. let topImg = document.getElementById("topImg");
  953. ctx.drawImage(topImg, 147.5, 65, 80, 80);
  954. this.shareData.poster = c.toDataURL('image/png');
  955. this.posterArr[this.list_index] = this.shareData.poster;
  956. console.info(this.shareData.poster);
  957. this.posterLoading = false;
  958. this.downloadShareImg('poster');
  959. } catch (error) {
  960. console.info(error);
  961. this.posterLoading = false;
  962. this.$message.error('生成失败');
  963. }
  964. },
  965. getMiniPoster() {
  966. try {
  967. // 存在海报则不重新生成
  968. // if (this.posterArr[this.list_index]) {
  969. // this.shareData.poster = this.posterArr[this.list_index];
  970. // return;
  971. // }
  972. this.posterLoading = true;
  973. let qrcodeInfo = document.getElementById("qrcode-info");
  974. var c = document.getElementById("myCanvas");
  975. // 清空上一个生成的海报
  976. c.remove();
  977. // 创建标签
  978. let addPosterDom = document.createElement("canvas")
  979. addPosterDom.setAttribute("id", "myCanvas");
  980. addPosterDom.setAttribute("width", "375");
  981. addPosterDom.setAttribute("height", "603");
  982. qrcodeInfo.appendChild(addPosterDom);
  983. c = document.getElementById("myCanvas");
  984. var ctx = c.getContext("2d");
  985. // 背景图
  986. let bak = document.getElementById("couponBak");
  987. ctx.drawImage(bak, 0, 0, 375, 603);
  988. // 圆
  989. ctx.beginPath();
  990. ctx.arc(187.5, 105, 40, 0, 2 * Math.PI);
  991. ctx.closePath();
  992. ctx.fillStyle = "#FFF";
  993. ctx.fill(); //填充颜色
  994. let mall_header_data = JSON.parse(localStorage.getItem("mall_header_data"));
  995. // 店名
  996. ctx.font = "bold 17px Arial";
  997. ctx.fillStyle = "#000";
  998. ctx.textAlign = 'center';
  999. ctx.fillText(this.mall_info.mall_name, 187.5, 175);
  1000. // 优惠券类型
  1001. ctx.font = "bold 14px Arial";
  1002. ctx.fillStyle = "#000";
  1003. ctx.textAlign = 'center';
  1004. ctx.fillText("送你一张优惠券", 187.5, 205);
  1005. // 额度
  1006. ctx.font = "bold 22px Arial";
  1007. ctx.fillStyle = "#DB0505";
  1008. ctx.textAlign = 'center';
  1009. // ctx.fillText(this.list[this.list_index].content,187.5,265);
  1010. ctx.fillText(this.list[this.list_index].name, 187.5, 265);
  1011. let type = this.list[this.list_index].appoint_type;
  1012. let typeStr = "全场可用";
  1013. if (type == 1) {
  1014. typeStr = "指定商品分类可用";
  1015. } else if (type == 2) {
  1016. typeStr = "指定商品可用";
  1017. }
  1018. // 可使用的类型
  1019. ctx.font = "14px Arial";
  1020. ctx.fillStyle = "#DB0505";
  1021. ctx.textAlign = 'center';
  1022. // ctx.fillText("全部商品任意金额可用",187.5,295);
  1023. ctx.fillText(typeStr, 187.5, 295);
  1024. // 小程序二维码
  1025. let code = document.getElementById("mini_qrcode").getElementsByTagName("img")[0];
  1026. ctx.drawImage(code, 140, 380.5, 95, 95);
  1027. // 商城头像
  1028. ctx.beginPath();
  1029. ctx.arc(187.25, 104.75, 36.25, 0, 2 * Math.PI);
  1030. ctx.clip();
  1031. let topImg = document.getElementById("topImg");
  1032. ctx.drawImage(topImg, 147.5, 65, 80, 80);
  1033. this.shareData.poster = c.toDataURL('image/png');
  1034. this.posterArr[this.list_index] = this.shareData.poster;
  1035. console.info(this.shareData.poster);
  1036. this.posterLoading = false;
  1037. this.downloadShareImg('poster');
  1038. } catch (error) {
  1039. console.info(error);
  1040. this.posterLoading = false;
  1041. this.$message.error('生成失败,请尝试刷新页面再试');
  1042. }
  1043. },
  1044. async convertUrlToBase64(url) {
  1045. try {
  1046. // 1. 添加时间戳避免缓存 ‌:ml-citation{ref="1" data="citationList"}
  1047. const timestamp = Date.now();
  1048. const finalUrl = url.includes('?')
  1049. ? `${url}&t=${timestamp}`
  1050. : `${url}?t=${timestamp}`;
  1051. // 2. 通过 fetch 获取图片数据 ‌:ml-citation{ref="1,2" data="citationList"}
  1052. const response = await fetch(finalUrl, {
  1053. mode: 'cors' // 声明跨域请求 ‌:ml-citation{ref="1,3" data="citationList"}
  1054. });
  1055. if (!response.ok) {
  1056. throw new Error(`HTTP错误: ${response.status}`);
  1057. }
  1058. // 3. 转换为 Blob 并读取为 Base64 ‌:ml-citation{ref="1,5" data="citationList"}
  1059. const blob = await response.blob();
  1060. return await new Promise((resolve, reject) => {
  1061. const reader = new FileReader();
  1062. reader.onloadend = () => resolve(reader.result);
  1063. reader.onerror = error => reject(error);
  1064. reader.readAsDataURL(blob);
  1065. });
  1066. } catch (err) {
  1067. // 4. 处理跨域等错误 ‌:ml-citation{ref="1,3" data="citationList"}
  1068. console.error('转换失败:', err);
  1069. if (err.message.includes('CORS')) {
  1070. this.$message.error('跨域错误: 请检查服务器CORS配置');
  1071. }
  1072. throw err;
  1073. }
  1074. },
  1075. async showStore(row, type) {
  1076. this.store_list_show = true;
  1077. this.couponName = row.name;
  1078. request({
  1079. params: {
  1080. r: 'coupon/default/get-store-list'
  1081. },
  1082. data: {
  1083. store_id: row.store_id
  1084. },
  1085. method: 'post'
  1086. }).then(e => {
  1087. this.loading = false;
  1088. if (e.data.code === 0) {
  1089. console.log(e.data.data);
  1090. this.storeList = e.data.data;
  1091. } else {
  1092. }
  1093. })
  1094. },
  1095. async showMch(row, type) {
  1096. this.mch_list_show = true;
  1097. this.couponName = row.name;
  1098. request({
  1099. params: {
  1100. r: 'coupon/default/get-mch-list'
  1101. },
  1102. data: {
  1103. mch_id: row.mch_id
  1104. },
  1105. method: 'post'
  1106. }).then(e => {
  1107. this.loading = false;
  1108. if (e.data.code === 0) {
  1109. this.mchList = e.data.data;
  1110. } else {
  1111. }
  1112. })
  1113. },
  1114. edit(row, type) {
  1115. switch (type) {
  1116. case 'total_count':
  1117. this.total_count = row.total_count;
  1118. this.total_count_id = row.id;
  1119. break;
  1120. }
  1121. },
  1122. cancelEdit(type) {
  1123. switch (type) {
  1124. case 'total_count':
  1125. this.total_count = 0;
  1126. this.total_count_id = 0;
  1127. break;
  1128. }
  1129. },
  1130. handle(type, data = null) {
  1131. let id = data ? parseInt(data.id) : '';
  1132. switch (type) {
  1133. case 'total_count':
  1134. data.total_count = this.total_count;
  1135. console.log('修改数量===》', data);
  1136. if (this.total_count < 1) {
  1137. this.$message.error('优惠券发放数量不能小于1');
  1138. return false;
  1139. }
  1140. param = {
  1141. id: id,
  1142. total_count: this.total_count,
  1143. };
  1144. this.do_total_count(param);
  1145. break;
  1146. }
  1147. this.cancelEdit(type);
  1148. },
  1149. do_total_count(params) {
  1150. let self = this;
  1151. request({
  1152. params: {
  1153. r: 'coupon/default/edit-coupon-total-count',
  1154. },
  1155. method: 'post',
  1156. data: params
  1157. }).then(e => {
  1158. if (e.data.code == 0) {
  1159. self.$message.success(e.data.msg);
  1160. self.loadData();
  1161. } else {
  1162. self.$message.error(e.data.msg);
  1163. }
  1164. }).catch(e => {
  1165. console.log(e);
  1166. });
  1167. },
  1168. }
  1169. })
  1170. </script>