order.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. use common\helpers\AddonHelper;
  4. ComponentHelper::loadComponentView('coupon-select', AddonHelper::getAddonRootPath('Coupon') . 'backend/views/components');
  5. // ComponentHelper::loadComponentView('com-dialog-select');
  6. ComponentHelper::loadComponentView('com-dialog-select');
  7. ?>
  8. <style>
  9. .app-share {
  10. padding-top: 12px;
  11. border-top: 1px solid #e2e2e2;
  12. margin-top: -20px;
  13. }
  14. .app-share .app-share-bg {
  15. position: relative;
  16. width: 310px;
  17. height: 360px;
  18. background-repeat: no-repeat;
  19. background-size: contain;
  20. background-position: center
  21. }
  22. .app-share .app-share-bg .title {
  23. width: 160px;
  24. height: 29px;
  25. line-height: 1;
  26. word-break: break-all;
  27. text-overflow: ellipsis;
  28. display: -webkit-box;
  29. -webkit-box-orient: vertical;
  30. -webkit-line-clamp: 2;
  31. overflow: hidden;
  32. }
  33. .app-share .app-share-bg .pic-image {
  34. background-repeat: no-repeat;
  35. background-position: 0 0;
  36. background-size: cover;
  37. width: 160px;
  38. height: 130px;
  39. }
  40. .el-card__header {
  41. padding: 8px 20px;
  42. }
  43. .el-form-item--mini.el-form-item, .el-form-item--small.el-form-item {
  44. margin: 5px;
  45. }
  46. .el-form-item__content, .el-form-item__label{
  47. margin-top: 10px;
  48. }
  49. .main_box {
  50. background: #fff;
  51. padding: 0 25px 25px;
  52. }
  53. .main_img_box {
  54. width: 376px;
  55. height: 760px;
  56. position: relative;
  57. margin-right: 48px;
  58. }
  59. .main_img {
  60. position: absolute;
  61. top: 0;
  62. left: 0;
  63. }
  64. .main_content {
  65. width: 750px;
  66. height: 1334px;
  67. position: absolute;
  68. top: 137px;
  69. left: 49.1%;
  70. transform: translateX(-50%);
  71. background-size:cover;
  72. background-repeat:no-repeat;
  73. background-position:center;
  74. border-radius: 0 0 77px 74px;
  75. scrollbar-width: none;
  76. zoom: 0.464;
  77. /* firefox */
  78. -ms-overflow-style: none;
  79. /* IE 10+ */
  80. overflow-x: hidden;
  81. overflow-y: hidden;
  82. }
  83. .main_content_img {
  84. position: absolute;
  85. top: 10px;
  86. left: 10px;
  87. right: 10px;
  88. bottom: 10px;
  89. background: url('resources/img/mall/decorate/sun_single.png') no-repeat center;
  90. background-size: 100%;
  91. padding: 20px; /* 设置内边距来实现边距效果 */
  92. }
  93. .main_content_border {
  94. position: absolute;
  95. top: 108px;
  96. left: 27px;
  97. width: 676px;
  98. height: 677px;
  99. background-color: transparent;
  100. border: 17px solid #000;
  101. border-radius: 27px 27px 0 0
  102. }
  103. .main_content_notch {
  104. position: absolute;
  105. top: 108px;
  106. left: 50%; /* 将左侧位置设置为50% */
  107. transform: translateX(-50%); /* 使用transform属性将元素水平居中 */
  108. }
  109. .main_content_priceBg {
  110. position: absolute;
  111. top: 808px;
  112. left: 56px;
  113. width: 264px;
  114. height: 64px;
  115. line-height: 64px;
  116. /* 背景颜色 */
  117. background-color: #ff4544; /* 红色背景 */
  118. border-radius: 48px; /* 圆角 */
  119. color: #ffffff;
  120. font-size:26px;
  121. padding:0 29px;
  122. }
  123. .edit_box .el-button {
  124. width: 158px;
  125. height: 35px;
  126. padding: 10px 20px;
  127. }
  128. .edit_box {
  129. padding-top: 40px;
  130. }
  131. .save_btn {
  132. margin-top: 80px;
  133. }
  134. /* 公共样式 */
  135. .flex {
  136. display: -webkit-box;
  137. display: -webkit-flex;
  138. /* #ifndef APP-NVUE */
  139. display: flex;
  140. /* #endif */
  141. }
  142. .flex-y-center {
  143. display: -webkit-box;
  144. display: -webkit-flex;
  145. /* #ifndef APP-NVUE */
  146. display: flex;
  147. /* #endif */
  148. -webkit-box-align: center;
  149. -webkit-align-items: center;
  150. -ms-flex-align: center;
  151. -ms-grid-row-align: center;
  152. align-items: center;
  153. }
  154. .default_tips {
  155. text-align: center;
  156. margin-top: 200px;
  157. color: #D0D2D6;
  158. font-size: 35px;
  159. }
  160. </style>
  161. <div id="app" v-cloak>
  162. <el-card class="box-card" v-loading="loading" shadow="never" style="border:0;min-width: 1200px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  163. <div class="form_box">
  164. <template>
  165. <el-card>
  166. <el-form :model="ruleForm" size="small" ref="ruleForm" label-width="150px">
  167. <el-tabs v-model="activeName">
  168. <el-tab-pane label="基础设置" name="basic">
  169. <?=ComponentHelper::loadComponentView('order/basic', __DIR__ . '/');?>
  170. </el-tab-pane>
  171. <el-tab-pane label="退货地址" name="refund">
  172. <?=ComponentHelper::loadComponentView('order/refund', __DIR__ . '/'); ?>
  173. </el-tab-pane>
  174. <el-tab-pane label="满邮减免" name="freight">
  175. <?=ComponentHelper::loadComponentView('order/freight', __DIR__ . '/'); ?>
  176. </el-tab-pane>
  177. <el-tab-pane label="抵扣设置" name="score">
  178. <?=ComponentHelper::loadComponentView('order/score', __DIR__ . '/'); ?>
  179. </el-tab-pane>
  180. <el-tab-pane label="营销设置" name="marketing">
  181. <?=ComponentHelper::loadComponentView('order/marketing', __DIR__ . '/'); ?>
  182. </el-tab-pane>
  183. <el-tab-pane label="业绩设置" name="achievement">
  184. <?=ComponentHelper::loadComponentView('order/achievement', __DIR__ . '/'); ?>
  185. </el-tab-pane>
  186. <el-tab-pane label="晒单设置" name="sun_single">
  187. <?=ComponentHelper::loadComponentView('order/sun_single', __DIR__ . '/'); ?>
  188. </el-tab-pane>
  189. </el-tabs>
  190. <el-button v-if="activeName=='basic' || activeName=='marketing'" :loading="btnLoading" class="button-item" type="primary" style="margin-top: 24px;" @click="submit" size="small">保存
  191. </el-button>
  192. </el-form>
  193. </el-card>
  194. </template>
  195. </div>
  196. </el-card>
  197. </div>
  198. <script src="<?= Yii::$app->request->baseUrl ?>/resources/unpkg/vuedraggable@2.18.1/dist/vuedraggable.umd.min.js"></script>
  199. <script>
  200. const app = new Vue({
  201. el: '#app',
  202. data() {
  203. return {
  204. loading: false,
  205. btnLoading: false,
  206. params: {},
  207. pay_after_link_show: '我的订单',
  208. defaultTabs: [
  209. {"name":"mall"}
  210. ],
  211. activeName: 'basic',
  212. dialogVisible: false,
  213. settingPop: false,
  214. isAdd: true,
  215. reloadData: false,
  216. couponLoading: false,
  217. addressForm: {
  218. consignee: '',
  219. name: '',
  220. mobile: '',
  221. address: ''
  222. },
  223. imgCaseImg: '',
  224. ruleForm: {
  225. // 基础设置
  226. order: {
  227. is_town:{title:'收货地址是否精确到镇',value:'0',remark:'收货地址精确到镇,用户收货地址需要选择镇'},
  228. payment_expire_time:{title:'未支付订单超时时间',value:10,remark:'注意:最长时间为7天,单位:分钟'},
  229. auto_receiving_time:{title:'自动确认收货时间',value:7,remark:'从发货到自动确认收货的时间,单位:天'},
  230. can_after_sale_time:{title:'可以申请售后时间',value:7,remark:'可以申请售后的时间,注意:分销订单中的已完成订单,只有订单已确认收货,并且时间超过设置的售后天数之后才计入其中!单位:天'},
  231. send_type:{
  232. title:'发货方式',
  233. value:[],
  234. remark:'需添加门店,到店自提方可生效',
  235. type:'checkbox',
  236. extra:{
  237. express:'快递配送',
  238. offline:'到店自提',
  239. city:'同城配送',
  240. }
  241. },
  242. pay_after_link:{title:'订单支付成功后跳转',value:10,remark:'订单支付成功后跳转的页面'},
  243. is_show_username:{title:'显示真实姓名',value:'0',remark:'在订单管理处是否显示真实姓名'},
  244. limit_multi_province:{title:'限制添加多个省份地址',value:'0',remark: '一个用户不可以添加多个省份的收货地址'},
  245. is_show_return_btn:{title:'放弃退换货按钮显示',value:'0',remark: '若开启放弃退换货,则用户可在订单详情处进行放弃退换货,订单直接变成已完成状态'},
  246. return_prompt_content:{title:'放弃退换货提示内容',value:'',remark: ''},
  247. is_show_positioning: {
  248. title: '显示定位按钮',
  249. value: 1,
  250. remark: '',
  251. },
  252. is_show_invoice: {
  253. title: '显示申请开票按钮',
  254. value: 0,
  255. remark: '',
  256. },
  257. is_stop_order: {
  258. title: '是否关闭下单',
  259. value: 0,
  260. remark: '',
  261. },
  262. is_show_update_address: {
  263. title: '是否隐藏修改地址',
  264. value: 0,
  265. remark: '开启后,前端将不再显示修改地址按钮',
  266. },
  267. score_deduct_value_list: {
  268. title: '折扣多选框',
  269. value: [],
  270. type:'checkbox',
  271. extra: [
  272. {name: '会员折扣价抵扣', value: 'member'},
  273. {name: '经销商内购商品抵扣', value: 'distributor'},
  274. ]
  275. },
  276. is_score_deduct_status: {
  277. title: '积分抵扣',
  278. value: 0,
  279. remark: '注释:开启此功能后,如果客户购买的商品有会员价抵扣了部分金额,被抵扣的金额将会以积分的形式被扣除,如:' +
  280. '商品价格100元,会员折扣7折,用户支付70元,剩余优惠的30元将以30积分(积分的比例在积分设置)被抵扣掉,若积分不足则无法生成订单',
  281. },
  282. is_designated_achievement_goods: {
  283. title: '指定商品可增加业绩',
  284. value: 0,
  285. remark: '开启后,只有指定的商品才能增加业绩',
  286. goodsIds: []
  287. },
  288. achievement_goods_ids: {
  289. value: [],
  290. },
  291. goods_deduct:{
  292. title: '内购抵扣',
  293. value: 'agent',
  294. remark: '当“渠道分红”及“渠道业绩”插件同时存在,被选中的插件的内购“商品抵扣”功能才能生效',
  295. },
  296. goods_deduct_list: {
  297. title: '内购抵扣选项',
  298. value: [],
  299. },
  300. bottom_background_color: [
  301. {required: true, message: '请选择底栏背景颜色', trigger: 'change'},
  302. ],
  303. inactive_color: [
  304. {required: true, message: '请选择文字颜色', trigger: 'change'},
  305. ],
  306. active_color: [
  307. {required: true, message: '请选择文字选中状态颜色', trigger: 'change'},
  308. ],
  309. },
  310. // 售后设置
  311. // return_address: {
  312. // consignee:{title:'收货人',value:'',remark: ''},
  313. // mobile:{title:'退货手机号',value:'',remark: ''},
  314. // address:{title:'退货地址',value:'',remark: ''}
  315. // },
  316. return_address:{
  317. return_address: {value:[]}
  318. },
  319. freight: {
  320. is_open:{title:'开启满邮减免',value:'0',remark:'开启后则会使用邮费满减规则'},
  321. full_reduce: {
  322. title:'满M元邮费减N元',
  323. value: [
  324. {
  325. full: 0.00,
  326. reduce: 0.00,
  327. },
  328. ],
  329. remark:''
  330. }
  331. },
  332. //营销设置
  333. marketing: {
  334. enable_marketing: {'title' : "是否开启全局营销配置", 'value' : 0},
  335. total_price: {'title': "订单消费金额条件", 'value':0.00},
  336. enable_give_score: {'title':"是否开启赠送积分", 'value': 0},
  337. enable_give_balance: {'title': "是否开启赠送余额", 'value': 0},
  338. enable_give_redpack: {'title': "是否开启赠送红包", 'value': 0},
  339. enable_give_coupon: {'title': "是否开启赠送优惠券", 'value': 0},
  340. score_give_setting: { //积分赠送配置
  341. 'title' : "积分赠送配置",
  342. 'value': {
  343. give_type: '1', //类型
  344. give_num: 0, //数量
  345. score_giving_goods_type: [], //商品类型
  346. score_giving_calculation: '0', //计算方式
  347. }
  348. },
  349. balance_give_setting: { //余额赠送配置
  350. 'title': "余额赠送配置",
  351. 'value': {
  352. give_type: '1', //类型
  353. give_num: 0, //数量
  354. }
  355. },
  356. redpack_give_setting: {//红包赠送配置
  357. 'title': "红包赠送配置",
  358. 'value': {
  359. give_type: '1', //类型
  360. give_num: 0, //数量
  361. }
  362. },
  363. coupon_give_setting: { //优惠券赠送配置
  364. 'title': "优惠券赠送配置",
  365. 'value': {
  366. multiple_selection: [],
  367. }
  368. },
  369. settlement: {
  370. 'title': "结算方式 1:支付成功,2:订单完成",
  371. 'value': 1
  372. }, //结算方式 1:支付成功,2:订单完成
  373. is_install_coupon: {
  374. 'title': "是否安装优惠券插件",
  375. 'value': 1 //0:未安装,1:已安装
  376. },
  377. is_installed_redpack: {
  378. 'title': "是否安装红包插件",
  379. 'value': 1 //0:未安装,1:已安装
  380. },
  381. },
  382. // 晒单
  383. sun_single:{
  384. setting:{title:'晒单设置',value:1,remark:''},
  385. type:{title:'类型',value:1,remark:''},
  386. border_color:{title:'边框颜色',value:'#ffdeb5',remark:''},
  387. price_bg_color:{title:'活动价背景颜色',value:'#eb3534',remark:''},
  388. price_font_color:{title:'活动价字体颜色',value:'#fff',remark:''},
  389. poster_background:{title:'海报底图',value:'',remark:''},
  390. poster_notch:{title:'刘海图',value:'',remark:''},
  391. },
  392. },
  393. achievementGoodsList: [],
  394. keyword: '',
  395. rules: {
  396. sun_single:{
  397. border_color: [
  398. {required: true, message: '请选择底栏背景颜色', trigger: 'change'},
  399. ],
  400. price_bg_color: [
  401. {required: true, message: '请选择文字颜色', trigger: 'change'},
  402. ],
  403. price_font_color: [
  404. {required: true, message: '请选择文字选中状态颜色', trigger: 'change'},
  405. ],
  406. }
  407. },
  408. predefineColors: [
  409. '#000',
  410. '#fff',
  411. '#888',
  412. '#ff4544'
  413. ],
  414. }
  415. },
  416. mounted: function() {
  417. this.loadData();
  418. },
  419. methods: {
  420. loadData() {
  421. if(this.loading === true) return;
  422. this.loading = true;
  423. request({
  424. params: {
  425. r: 'mall/setting/edit',
  426. type: 'mall_order',
  427. },
  428. method: 'get'
  429. }).then(e => {
  430. this.loading = false;
  431. if (e.data.code == 0) {
  432. if(e.data.data) {//有选中的
  433. var data = e.data.data;
  434. Object.keys(this.ruleForm).forEach((key) => {
  435. Object.keys(this.ruleForm[key]).forEach((k) => {
  436. if (data[key][k]) {
  437. var dataValue = data[key][k].value;
  438. if(data[key][k].value!=null){
  439. if (typeof dataValue == 'string' && (dataValue.indexOf("{") !== -1 || dataValue.indexOf("[") !== -1)) {
  440. // 将json字符串转为对象
  441. if (k == 'pay_after_link') {
  442. var pay_after_link = JSON.parse(data[key][k].value);
  443. this.pay_after_link_show = pay_after_link.params.title;
  444. this.ruleForm[key][k].value = data[key][k].value;
  445. } else {
  446. this.ruleForm[key][k].value = JSON.parse(data[key][k].value);
  447. }
  448. }else{
  449. this.ruleForm[key][k].value = data[key][k].value;
  450. }
  451. }
  452. }
  453. });
  454. });
  455. this.achievementGoodsList = data.achievementGoodsList ?? []
  456. }
  457. }
  458. console.log(this.ruleForm.return_address.return_address)
  459. }).catch(e => {
  460. this.loading = false;
  461. })
  462. },
  463. submit() {
  464. if(!Number.isFinite(this.ruleForm.order.payment_expire_time.value)){
  465. this.$message.error('设置未支付订单超时时间只能是数字');
  466. return false;
  467. }if(this.ruleForm.order.payment_expire_time.value<10){
  468. this.$message.error('设置未支付订单超时时间不能低于10分钟');
  469. return false;
  470. }
  471. if (this.ruleForm.return_address.return_address.value.length == 0) {
  472. this.$message.error('请添加退货地址');
  473. return false;
  474. }
  475. // 判断如果开启营销配置。商品类型必须选择
  476. if (this.ruleForm.marketing.enable_marketing.value && this.ruleForm.marketing.score_give_setting.value.score_giving_goods_type.length === 0) {
  477. this.$message.error('营销设置-商品类型必须选择一项');
  478. return false;
  479. }
  480. // 选择的业绩商品写入到goodsIds
  481. this.ruleForm.order.achievement_goods_ids.value = []
  482. console.log(this.achievementGoodsList)
  483. for (const achievementGoodsItem of this.achievementGoodsList) {
  484. this.ruleForm.order.achievement_goods_ids.value.push(achievementGoodsItem.id)
  485. }
  486. this.btnLoading = true;
  487. this.$request({
  488. params: {
  489. r: 'mall/setting/edit',
  490. },
  491. method: 'post',
  492. data: {
  493. setting: this.ruleForm,
  494. },
  495. }).then(e => {
  496. this.ruleForm.order.achievement_goods_ids.value = []
  497. this.btnLoading = false;
  498. if (e.data.code === 0) {
  499. this.$message.success(e.data.msg);
  500. } else {
  501. this.$message.error(e.data.msg);
  502. }
  503. this.loading = false;
  504. this.settingPop = false;
  505. }).catch(e => {
  506. this.btnLoading = false;
  507. this.loading = false;
  508. this.settingPop = false;
  509. });
  510. },
  511. selectLinkUrl(e) {
  512. let self = this;
  513. e.forEach(function (item, index) {
  514. self.ruleForm.link_url = item.new_link_url;
  515. self.ruleForm.link = item;
  516. })
  517. },
  518. picUrl(e) {
  519. if (e.length) {
  520. this.ruleForm.pic_url = e[0].url;
  521. this.$refs.ruleForm.validateField('pic_url');
  522. }
  523. },
  524. imgCase(img) {
  525. this.dialogVisible = true;
  526. this.imgCaseImg = img;
  527. },
  528. selectUrl(e) {
  529. let self = this;
  530. let link_data = {};
  531. console.log(e);
  532. e.forEach(function (item) {
  533. self.pay_after_link_show = item.title;
  534. link_data = {
  535. route: item.route,
  536. open_type: item.open_type,
  537. params: item.params,
  538. }
  539. });
  540. self.ruleForm.order.pay_after_link.value = JSON.stringify(link_data);
  541. },
  542. //添加地址
  543. addAddress() {
  544. console.log(this.ruleForm.return_address.return_address.value)
  545. this.loading = true;
  546. for (let i in this.addressForm) {
  547. if (this.addressForm[i] == '') {
  548. this.$message.error('内容不能为空');
  549. return false;
  550. }
  551. }
  552. if (this.isAdd) {
  553. this.ruleForm.return_address.return_address.value.push(this.addressForm);
  554. }
  555. this.submit();
  556. this.reloadData = true;
  557. },
  558. //删除地址
  559. delAddress(index) {
  560. this.$confirm('删除该地址, 是否继续?', '提示', {
  561. confirmButtonText: '确定',
  562. cancelButtonText: '取消',
  563. type: 'warning'
  564. }).then(() => {
  565. this.loading = true;
  566. if (this.ruleForm.return_address.return_address.value && this.ruleForm.return_address.return_address.value.length > index) {
  567. this.ruleForm.return_address.return_address.value.splice(index, 1);
  568. }
  569. console.log();
  570. this.submit(this.ruleForm.return_address.return_address.value);
  571. this.loading = false;
  572. })
  573. },
  574. //显示添加弹窗
  575. showPop() {
  576. this.isAdd = true;
  577. this.settingPop = true;
  578. this.addressForm = {};
  579. },
  580. //修改地址
  581. editAddress(index,data) {
  582. this.settingPop = true;
  583. this.isAdd = false;
  584. this.addressForm = {};
  585. this.$set(this.addressForm, 'name', data.name);
  586. this.$set(this.addressForm, 'consignee', data.consignee);
  587. this.$set(this.addressForm, 'mobile', data.mobile);
  588. this.$set(this.addressForm, 'address', data.address);
  589. this.ruleForm.return_address.return_address.value[index] = this.addressForm;
  590. console.log(this.ruleForm.return_address.return_address.value);
  591. },
  592. // 操作处理
  593. handle(type, data = null) {
  594. switch (type) {
  595. case 'freight_add':// 添加满邮
  596. this.ruleForm.freight.full_reduce.value.push({
  597. full:"0.00",
  598. reduce:"0.00",
  599. });
  600. break;
  601. case 'freight_del':// 删除满邮
  602. this.ruleForm.freight.full_reduce.value.splice(data,1);
  603. break;
  604. case 'coupon_select':
  605. this.couponLoading = true;
  606. break;
  607. case 'coupon_delete':
  608. console.log(this.ruleForm.marketing.coupon_give_setting.value);
  609. this.ruleForm.marketing.coupon_give_setting.value.multiple_selection.splice(data, 1);
  610. this.$forceUpdate();
  611. break;
  612. }
  613. },
  614. handleCoupon(data) {
  615. this.couponLoading = false;
  616. this.ruleForm.marketing.coupon_give_setting.value.multiple_selection = data
  617. console.log(this.ruleForm.marketing.coupon_give_setting.value);
  618. },
  619. handleGiveTypeChange(pindex) {
  620. if (this.ruleForm.marketing[pindex].value.give_type == 2) {
  621. let giveNum = this.ruleForm.marketing[pindex].value.give_num
  622. giveNum = giveNum ? giveNum : 0
  623. this.ruleForm.marketing[pindex].value.give_num = parseInt(giveNum)
  624. }
  625. },
  626. formatGiveNumber(value, pindex) {
  627. if (this.ruleForm.marketing[pindex].value.give_type == 2) {
  628. this.ruleForm.marketing[pindex].value.give_num = value.replace(/[^\d]/g, "")
  629. if ( this.ruleForm.marketing[pindex].value.give_num > 100) {
  630. this.ruleForm.marketing[pindex].value.give_num = 100;
  631. }
  632. } else {
  633. let temp = value.toString();
  634. temp = temp.replace(/。/g, ".");
  635. temp = temp.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
  636. temp = temp.replace(/^\./g, ""); //验证第一个字符是数字
  637. temp = temp.replace(/\.{2,}/g, ""); //只保留第一个, 清除多余的
  638. temp = temp.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  639. temp = temp.replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3");
  640. this.ruleForm.marketing[pindex].value.give_num = temp
  641. }
  642. },
  643. marketingOpen(val) {
  644. if (val == 1) {
  645. this.ruleForm.marketing.enable_marketing.value = 0;
  646. this.$confirm('开启此开关,商城所有订单满足消费条件都将会进行赠送,请谨慎开启', '提示', {
  647. confirmButtonText: '确定',
  648. cancelButtonText: '取消',
  649. type: 'warning'
  650. }).then(() => {
  651. this.ruleForm.marketing.enable_marketing.value = 1;
  652. }).catch(() => {
  653. this.ruleForm.marketing.enable_marketing.value = 0;
  654. });
  655. }
  656. },
  657. // 业绩商品选择
  658. achievementGoodsSelect(goodsList) {
  659. for (const goodsItem of goodsList) {
  660. let flag = true
  661. for (const achievementGoodsItem of this.achievementGoodsList) {
  662. if (goodsItem.id === achievementGoodsItem.id) {
  663. flag = false
  664. break
  665. }
  666. }
  667. if (flag) {
  668. this.achievementGoodsList.push(goodsItem)
  669. }
  670. }
  671. },
  672. // 删除业绩商品
  673. deleteAchievementGoods(index) {
  674. this.achievementGoodsList.splice(index, 1)
  675. },
  676. // 切换模板、DIY
  677. changeSingleType(e){
  678. if (e == 0) {
  679. }
  680. },
  681. // 保存海报
  682. savePoster(){
  683. this.$request({
  684. params: {
  685. r: 'mall/setting/edit',
  686. },
  687. method: 'post',
  688. data: {
  689. setting: this.ruleForm,
  690. },
  691. }).then(e => {
  692. if (e.data.code == 0) {
  693. this.$message({
  694. message: '保存成功!',
  695. type: 'success'
  696. });
  697. } else {
  698. this.$message.error(e.data.msg);
  699. }
  700. });
  701. }
  702. }
  703. });
  704. </script>