store.php 83 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756
  1. <?php
  2. Yii::$app->loadComponentView('com-rich-text');
  3. Yii::$app->loadComponentView('goods/com-dialog-select');
  4. Yii::$app->loadComponentView('goods/com-attr');
  5. Yii::$app->loadComponentView('goods/com-attr-select');
  6. Yii::$app->loadComponentView('goods/com-add-cat');
  7. Yii::$app->loadComponentView('goods/com-select-goods');
  8. Yii::$app->loadComponentView('goods/com-area-limit');
  9. Yii::$app->loadComponentView('goods/com-preview');
  10. Yii::$app->loadComponentView('goods/com-attr-group');
  11. Yii::$app->loadComponentView('goods/com-goods-area');
  12. Yii::$app->loadComponentView('goods/com-goods-currency-area');
  13. Yii::$app->loadComponentView('goods/com-goods-agent');
  14. Yii::$app->loadComponentView('goods/com-goods-currency-agent');
  15. Yii::$app->loadComponentView('mall/choose-user','@app/plugins/o2o_store/views/components');
  16. ?>
  17. <style>
  18. .mt-24 {
  19. margin-bottom: 24px;
  20. }
  21. .com-goods .el-form-item__label {
  22. padding: 0 20px 0 0;
  23. }
  24. .com-goods .el-dialog__body h3 {
  25. font-weight: normal;
  26. color: #999999;
  27. }
  28. .com-goods .form-body {
  29. padding: 10px 20px 20px;
  30. background-color: #fff;
  31. margin-bottom: 30px;
  32. }
  33. .com-goods .button-item {
  34. padding: 9px 25px;
  35. margin-bottom: 10px;
  36. }
  37. .com-goods .sortable-chosen {
  38. /* border: 2px solid #3399ff; */
  39. }
  40. .del-btn {
  41. position: absolute;
  42. right: -8px;
  43. top: -8px;
  44. padding: 4px 4px;
  45. }
  46. .com-goods .app-share {
  47. padding-top: 12px;
  48. border-top: 1px solid #e2e2e2;
  49. margin-top: -20px;
  50. }
  51. .com-goods .app-share .app-share-bg {
  52. position: relative;
  53. width: 310px;
  54. height: 360px;
  55. background-repeat: no-repeat;
  56. background-size: contain;
  57. background-position: center
  58. }
  59. .com-goods .app-share .app-share-bg .title {
  60. width: 160px;
  61. height: 29px;
  62. line-height: 1;
  63. word-break: break-all;
  64. text-overflow: ellipsis;
  65. display: -webkit-box;
  66. -webkit-box-orient: vertical;
  67. -webkit-line-clamp: 2;
  68. overflow: hidden;
  69. }
  70. .com-goods .app-share .app-share-bg .pic-image {
  71. background-repeat: no-repeat;
  72. background-position: 0 0;
  73. background-size: cover;
  74. width: 160px;
  75. height: 130px;
  76. }
  77. .bottom-div {
  78. border-top: 1px solid #E3E3E3;
  79. position: fixed;
  80. bottom: 0;
  81. background-color: #ffffff;
  82. z-index: 999;
  83. padding: 10px;
  84. width: 80%;
  85. }
  86. .com-goods .add-image-btn {
  87. width: 100px;
  88. height: 100px;
  89. color: #419EFB;
  90. border: 1px solid #e2e2e2;
  91. cursor: pointer;
  92. }
  93. .com-goods .pic-url-remark {
  94. font-size: 13px;
  95. color: #c9c9c9;
  96. margin-bottom: 12px;
  97. }
  98. .com-goods .customize-share-title {
  99. margin-top: 10px;
  100. width: 80px;
  101. height: 80px;
  102. position: relative;
  103. cursor: move;
  104. }
  105. .com-goods .share-title {
  106. font-size: 16px;
  107. color: #303133;
  108. padding-bottom: 22px;
  109. border-bottom: 1px solid #e2e2e2;
  110. }
  111. .box-grow-0 {
  112. /* flex 子元素固定宽度*/
  113. min-width: 0;
  114. -webkit-box-flex: 0;
  115. -webkit-flex-grow: 0;
  116. -ms-flex-positive: 0;
  117. flex-grow: 0;
  118. -webkit-flex-shrink: 0;
  119. -ms-flex-negative: 0;
  120. flex-shrink: 0;
  121. }
  122. </style>
  123. <template id="store">
  124. <el-card shadow="never" style="border:0" body-style="background-color: #f3f3f3;padding: 10px 0 0;" class="com-goods" v-loading="cardLoading">
  125. <div class='form-body'>
  126. <el-form :model="cForm" :rules="cRule" ref="ruleForm" label-width="180px" size="small" class="demo-ruleForm">
  127. <el-tabs v-model="activeName" @tab-click="handleClick">
  128. <el-tab-pane label="基本设置" name="first">
  129. <el-card shadow="never" class="mt-24">
  130. <div slot="header">
  131. <span>开店会员</span>
  132. </div>
  133. <el-row>
  134. <el-col :xl="12" :lg="16">
  135. <el-form-item prop="user_id_list">
  136. <label slot="label">
  137. <span>会员ID</span>
  138. </label>
  139. <el-input style="width: 80%" placeholder="请输入分享标题" v-model="ruleForm.app_share_title"></el-input>
  140. <el-button type="primary" size="small" style="width:19%;padding: 9px 15px !important;" @click="chooseUser">选择会员
  141. </el-button>
  142. </el-form-item>
  143. <el-form-item prop="app_share_title">
  144. <label slot="label">
  145. <span>会员昵称</span>
  146. </label>
  147. <el-input placeholder="请输入分享标题" v-model="ruleForm.app_share_title"></el-input>
  148. </el-form-item>
  149. <el-form-item prop="app_share_title">
  150. <label slot="label">
  151. <span>绑定手机号</span>
  152. </label>
  153. <el-input placeholder="请输入分享标题" v-model="ruleForm.app_share_title"></el-input>
  154. </el-form-item>
  155. </el-col>
  156. </el-row>
  157. </el-card>
  158. <!-- 基本信息 -->
  159. <slot name="before_info"></slot>
  160. <el-card shadow="never" class="mt-24">
  161. <div slot="header">
  162. <span>基本信息</span>
  163. </div>
  164. <el-row>
  165. <el-col :xl="12" :lg="16">
  166. <el-form-item prop="app_share_title">
  167. <label slot="label">
  168. <span>会员昵称</span>
  169. </label>
  170. <el-input placeholder="请输入分享标题" v-model="ruleForm.app_share_title"></el-input>
  171. </el-form-item>
  172. <el-form-item prop="app_share_pic">
  173. <label slot="label">
  174. <span>自定义分享图片</span>
  175. <el-tooltip class="item" effect="dark" content="分享给好友时,作为分享图片" placement="top">
  176. <i class="el-icon-info"></i>
  177. </el-tooltip>
  178. </label>
  179. <com-attachment v-model="ruleForm.app_share_pic" :multiple="false" :max="1">
  180. <el-tooltip class="item" effect="dark" content="建议尺寸:420 * 336" placement="top">
  181. <el-button size="mini">选择图片</el-button>
  182. </el-tooltip>
  183. </com-attachment>
  184. <div class="customize-share-title">
  185. <com-image mode="aspectFill" width='80px' height='80px' :src="ruleForm.app_share_pic ? ruleForm.app_share_pic : ''"></com-image>
  186. <el-button v-if="ruleForm.app_share_pic" class="del-btn" size="mini" type="danger" icon="el-icon-close" circle @click="ruleForm.app_share_pic = ''"></el-button>
  187. </div>
  188. <el-button @click="app_share.dialog = true;app_share.type = 'pic_bg'" type="text">查看图例
  189. </el-button>
  190. </el-form-item>
  191. <!-- 自定义 -->
  192. <el-dialog :title="app_share['type'] == 'pic_bg' ? `查看自定义分享图片图例`:`查看自定义分享标题图例`" :visible.sync="app_share.dialog" width="30%">
  193. <div flex="dir:left main:center" class="app-share">
  194. <div class="app-share-bg" :style="{backgroundImage: 'url('+app_share[app_share.type]+')'}"></div>
  195. </div>
  196. <div slot="footer" class="dialog-footer">
  197. <el-button @click="app_share.dialog = false" type="primary">我知道了</el-button>
  198. </div>
  199. </el-dialog>
  200. </el-col>
  201. </el-row>
  202. </el-card>
  203. <!-- 商品服务 -->
  204. <slot name="before_goods"></slot>
  205. <el-card shadow="never" class="mt-24">
  206. <div slot="header">
  207. <span>商品服务</span>
  208. </div>
  209. <el-row>
  210. <el-col :xl="12" :lg="16">
  211. <el-form-item label="商品服务">
  212. <template v-if="!defaultServiceChecked">
  213. <el-tag v-for="(service, index) in ruleForm.services" @close="serviceDelete(index)" :key="service.id" :disable-transitions="true" style="margin-right: 10px;" closable>
  214. {{service.name}}
  215. </el-tag>
  216. <el-button type="button" size="mini" @click="serviceOpen">新增服务
  217. </el-button>
  218. <el-dialog title="选择商品服务" :visible.sync="service.dialog" width="30%">
  219. <el-card shadow="never" flex="dir:left" style="flex-wrap: wrap" v-loading="service.loading">
  220. <el-checkbox-group v-model="service.list">
  221. <el-checkbox v-for="item in service.services" :label="item" :key="item.id">{{item.name}}
  222. </el-checkbox>
  223. </el-checkbox-group>
  224. </el-card>
  225. <div slot="footer" class="dialog-footer">
  226. <el-button @click="serviceCancel">取 消</el-button>
  227. <el-button type="primary" @click="serviceConfirm">确 定</el-button>
  228. </div>
  229. </el-dialog>
  230. </template>
  231. <el-checkbox v-model="defaultServiceChecked" @change="defaultService()">默认服务
  232. </el-checkbox>
  233. </el-form-item>
  234. <el-form-item prop="freight_id">
  235. <template slot='label'>
  236. <span>运费设置</span>
  237. <el-tooltip effect="dark" content="选择第一项(默认运费)将会根据运费管理的(默认运费)变化而变化" placement="top">
  238. <i class="el-icon-info"></i>
  239. </el-tooltip>
  240. </template>
  241. <el-tag @close="freightDelete()" v-if="ruleForm.freight" :key="ruleForm.freight.name" :disable-transitions="true" style="margin-right: 10px;" closable>
  242. {{ruleForm.freight.name}}
  243. </el-tag>
  244. <el-button type="button" size="mini" @click="freightOpen">选择运费
  245. </el-button>
  246. <el-dialog title="选择运费" :visible.sync="freight.dialog" width="30%">
  247. <el-card shadow="never" flex="dir:left" style="flex-wrap: wrap" v-loading="freight.loading">
  248. <el-radio-group v-model="freight.checked">
  249. <el-radio style="padding: 10px;" v-for="item in freight.list" :label="item" :key="item.id">{{item.name}}
  250. </el-radio>
  251. </el-radio-group>
  252. </el-card>
  253. <div slot="footer" class="dialog-footer">
  254. <el-button @click="freightCancel">取 消</el-button>
  255. <el-button type="primary" @click="freightConfirm">确 定</el-button>
  256. </div>
  257. </el-dialog>
  258. </el-form-item>
  259. <el-form-item label="限购数量" prop="confine_count">
  260. <div flex="dir:left">
  261. <span class="box-grow-0" style="color:#606266">商品</span>
  262. <div style="width: 100%;margin:0 10px">
  263. <el-input oninput="this.value = this.value.replace(/[^0-9]/g, '');" :disabled="ruleForm.confine_count <= -1" placeholder="请输入限购数量" v-model="ruleForm.confine_count">
  264. <template slot="append">件</template>
  265. </el-input>
  266. </div>
  267. <el-checkbox style="margin-left: 5px;" @change="itemChecked" v-model="ruleForm.confine_count <= -1">无限制
  268. </el-checkbox>
  269. </div>
  270. <div flex="dir:left" style="margin-top: 10px;">
  271. <span class="box-grow-0" style="color:#606266">订单</span>
  272. <div style="width: 100%;margin:0 10px">
  273. <el-input oninput="this.value = this.value.replace(/[^0-9]/g, '');" :disabled="ruleForm.confine_order_count <= -1" placeholder="请输入限购数量" v-model="ruleForm.confine_order_count">
  274. <template slot="append">单</template>
  275. </el-input>
  276. </div>
  277. <el-checkbox style="margin-left: 5px;" @change="itemOrderChecked" v-model="ruleForm.confine_order_count <= -1">无限制
  278. </el-checkbox>
  279. </div>
  280. </el-form-item>
  281. <el-form-item label="" prop="pieces">
  282. <template slot='label'>
  283. <span>单品满件包邮</span>
  284. <el-tooltip effect="dark" content="如果设置0或空,则不支持满件包邮" placement="top">
  285. <i class="el-icon-info"></i>
  286. </el-tooltip>
  287. </template>
  288. <el-input type="number" min="0" oninput="" placeholder="请输入数量" v-model="ruleForm.pieces">
  289. <template slot="append">件</template>
  290. </el-input>
  291. </el-form-item>
  292. <el-form-item prop="forehead">
  293. <template slot='label'>
  294. <span>单品满额包邮</span>
  295. <el-tooltip effect="dark" content="如果设置0或空,则不支持满额包邮" placement="top">
  296. <i class="el-icon-info"></i>
  297. </el-tooltip>
  298. </template>
  299. <el-input type="number" oninput="this.value = this.value.replace(/[^0-9\.]/, '');" min="0" placeholder="请输入金额" v-model="ruleForm.forehead">
  300. <template slot="append">元</template>
  301. </el-input>
  302. </el-form-item>
  303. <el-form-item label="配送范围" prop="is_area_limit">
  304. <el-switch
  305. v-model="ruleForm.is_area_limit"
  306. :active-value="1"
  307. :inactive-value="0">
  308. </el-switch>
  309. </el-form-item>
  310. <el-form-item v-if="ruleForm.is_area_limit" label="允许购买区域" prop="area_limit">
  311. <com-area-limit v-model="ruleForm.area_limit"></com-area-limit>
  312. </el-form-item>
  313. </el-col>
  314. </el-row>
  315. </el-card>
  316. <!-- 商品详情 -->
  317. <slot name="before_detail"></slot>
  318. <el-card shadow="never" class="mt-24">
  319. <div slot="header">
  320. <span>商品详情</span>
  321. </div>
  322. <el-row>
  323. <el-col :xl="12" :lg="16">
  324. <el-form-item label="商品详情">
  325. <com-rich-text style="width: 750px" v-model="ruleForm.detail"></com-rich-text>
  326. </el-form-item>
  327. </el-col>
  328. </el-row>
  329. </el-card>
  330. <slot name="after_detail"></slot>
  331. </el-tab-pane>
  332. <el-tab-pane label="营业设置" name="eighth">
  333. <!-- 单品满额减免 begin -->
  334. <el-card shadow="never" class="mt-24">
  335. <div slot="header">
  336. <span>单品满额减免</span>
  337. </div>
  338. <el-row>
  339. <el-col :xl="12" :lg="16">
  340. <el-form-item prop="fulfil_price">
  341. <template slot='label'>
  342. <span>单品满额金额</span>
  343. <el-tooltip effect="dark" content="单品达到该金额可减免一定金额,如果设置0或空,则不支持单品满额减免" placement="top">
  344. <i class="el-icon-info"></i>
  345. </el-tooltip>
  346. </template>
  347. <el-input type="number" oninput="this.value = this.value.replace(/[^0-9\.]/, '');" min="0" placeholder="请输入金额" v-model="ruleForm.fulfil_price" @input="change($event)">
  348. <template slot="append">元</template>
  349. </el-input>
  350. </el-form-item>
  351. <el-form-item prop="full_relief_price">
  352. <template slot='label'>
  353. <span>单品满额减免金额</span>
  354. <el-tooltip effect="dark" content="单品达到该金额可减免一定金额,如果设置0或空,则不支持单品满额减免" placement="top">
  355. <i class="el-icon-info"></i>
  356. </el-tooltip>
  357. </template>
  358. <el-input type="number" @input="change($event)" oninput="this.value = this.value.replace(/[^0-9\.]/, '');" min="0" placeholder="请输入金额" v-model="ruleForm.full_relief_price">
  359. <template slot="append">元</template>
  360. </el-input>
  361. </el-form-item>
  362. </el-col>
  363. </el-row>
  364. </el-card>
  365. <!-- 单品满额减免 end -->
  366. <!-- 显示设置 todo -->
  367. <el-card shadow="never" class="mt-24" v-if="false && is_show == 1">
  368. <div slot="header">
  369. <span>显示设置</span>
  370. </div>
  371. </el-card>
  372. <!-- 营销设置 -->
  373. <slot name="before_marketing"></slot>
  374. <el-card shadow="never" class="mt-24">
  375. <div slot="header">
  376. <span>营销设置</span>
  377. </div>
  378. <span>积分</span>
  379. <el-row>
  380. <el-col :xl="12" :lg="16">
  381. <el-form-item>
  382. <template slot='label'>
  383. <span>积分赠送</span>
  384. <el-tooltip effect="dark" placement="top">
  385. <div slot="content">用户购物赠送的积分, 如果不填写或填写0,则默认为不赠送积分,
  386. 如果为百分比则为按成交价格的比例计算积分"<br />
  387. 如: 购买2件,设置10 积分, 不管成交价格是多少, 则购买后获得20积分</br>
  388. 如: 购买2件,设置10%积分, 成交价格2 * 200= 400, 则购买后获得 40 积分(400*10%)
  389. </div>
  390. <i class="el-icon-info"></i>
  391. </el-tooltip>
  392. </template>
  393. <el-input type="number" min="0" oninput="this.value = this.value.replace(/[^0-9]/g, '');" placeholder="请输入赠送积分数量" v-model="ruleForm.give_score">
  394. <template slot="append">
  395. <el-radio v-model="ruleForm.give_score_type" :label="1">固定值
  396. </el-radio>
  397. <el-radio v-model="ruleForm.give_score_type" :label="2">百分比
  398. </el-radio>
  399. </template>
  400. </el-input>
  401. </el-form-item>
  402. <el-form-item>
  403. <template slot='label'>
  404. <span>积分抵扣</span>
  405. <el-tooltip effect="dark" content="如果设置0,则不支持积分抵扣" placement="top">
  406. <i class="el-icon-info"></i>
  407. </el-tooltip>
  408. </template>
  409. <el-input :disabled="ruleForm.full_forehead_score==1" type="number" min="0" oninput="this.value = this.value.replace(/[^0-9\.]/g, '');" placeholder="请输最高抵扣金额" v-model="ruleForm.forehead_score">
  410. <template slot="prepend">最多抵扣</template>
  411. <template slot="append">
  412. <el-radio v-model="ruleForm.forehead_score_type" :label="1" :disabled="ruleForm.full_forehead_score==1">固定值
  413. </el-radio>
  414. <el-radio style="display: none" v-model="ruleForm.forehead_score_type" :label="2">百分比
  415. </el-radio>
  416. </template>
  417. </el-input>
  418. <el-checkbox :true-label="1" :false-label="0" :disabled="ruleForm.full_forehead_score==1" v-model="ruleForm.accumulative">
  419. 允许多件累计抵扣
  420. </el-checkbox>
  421. <el-checkbox :true-label="1" :false-label="0" @change="fullForeheadScore" v-model="ruleForm.full_forehead_score">
  422. 允许全额抵扣
  423. </el-checkbox>
  424. </el-form-item>
  425. </el-col>
  426. </el-row>
  427. <template v-for="item in ruleForm.currency_deduct_setting">
  428. <!-- <span>{{currencyName(item.currency_code)}}</span> -->
  429. <!-- <span>{{item.currency_code | currencyName}}</span> -->
  430. <template v-for="its in currencyList">
  431. <span v-if="its.code==item.currency_code">{{its.name}}</span>
  432. </template>
  433. <el-row>
  434. <template>
  435. <el-col :xl="12" :lg="16">
  436. <el-form-item>
  437. <template slot='label'>
  438. <template v-for="its in currencyList">
  439. <span v-if="its.code==item.currency_code">{{its.name}}赠送</span>
  440. </template>
  441. <!-- <el-tooltip effect="dark" placement="top">
  442. <div slot="content">用户购物赠送的积分, 如果不填写或填写0,则默认为不赠送积分,
  443. 如果为百分比则为按成交价格的比例计算积分"<br />
  444. 如: 购买2件,设置10 积分, 不管成交价格是多少, 则购买后获得20积分</br>
  445. 如: 购买2件,设置10%积分, 成交价格2 * 200= 400, 则购买后获得 40 积分(400*10%)
  446. </div>
  447. <i class="el-icon-info"></i>
  448. </el-tooltip> -->
  449. </template>
  450. <el-input type="number" min="0" oninput="this.value = this.value.replace(/[^0-9]/g, '');" placeholder="请输入赠送积分数量" v-model="item.give_num">
  451. <template slot="append">
  452. <template v-for="its in currencyList">
  453. <template v-if="its.code==item.currency_code">{{its.unit}}</template>
  454. </template>
  455. <el-radio v-model="item.is_percent_give" :label="'0'">固定值
  456. </el-radio>
  457. <el-radio v-model="item.is_percent_give" :label="'1'">百分比
  458. </el-radio>
  459. </template>
  460. </el-input>
  461. </el-form-item>
  462. <el-form-item>
  463. <template slot='label'>
  464. <template v-for="its in currencyList">
  465. <span v-if="its.code==item.currency_code">{{its.name}}抵扣</span>
  466. </template>
  467. <!-- <el-tooltip effect="dark" content="如果设置0,则不支持积分抵扣" placement="top">
  468. <i class="el-icon-info"></i>
  469. </el-tooltip> -->
  470. </template>
  471. <el-input type="number" min="0" oninput="this.value = this.value.replace(/[^0-9\.]/g, '');" placeholder="请输最高抵扣金额" v-model="item.max_deduction_num">
  472. <template slot="prepend">最多抵扣</template>
  473. <template slot="append">
  474. <el-radio v-model="ruleForm.forehead_score_type" :label="1" :disabled="ruleForm.full_forehead_score==1">固定值
  475. </el-radio>
  476. <el-radio style="display: none" v-model="ruleForm.forehead_score_type" :label="2">百分比
  477. </el-radio>
  478. </template>
  479. </el-input>
  480. <el-radio v-model="item.deduction_type" :label="'1'">
  481. 允许单件抵扣
  482. </el-radio>
  483. <el-radio v-model="item.deduction_type" :label="'2'">
  484. 允许多件累计抵扣
  485. </el-radio>
  486. </el-form-item>
  487. </el-col>
  488. </template>
  489. </el-row>
  490. </template>
  491. </el-card>
  492. </el-tab-pane>
  493. <el-tab-pane label="有效期设置" name="ninth">
  494. <slot name="before_goods"></slot>
  495. <el-card shadow="never" class="mt-24">
  496. <el-row>
  497. <el-col :xl="12" :lg="16">
  498. <el-form-item label="配送范围" prop="is_area_limit">
  499. <el-switch v-model="ruleForm.is_area_limit" :active-value="1" :inactive-value="0">
  500. </el-switch>
  501. </el-form-item>
  502. <el-form-item v-if="ruleForm.is_area_limit" label="允许购买区域" prop="area_limit">
  503. <com-area-limit v-model="ruleForm.area_limit"></com-area-limit>
  504. </el-form-item>
  505. </el-col>
  506. </el-row>
  507. </el-card>
  508. </el-tab-pane>
  509. <el-tab-pane label="账号密码设置" name="second">
  510. <el-form-item label="是否享受会员功能" prop="is_level">
  511. <el-switch :active-value="1" :inactive-value="0" v-model="ruleForm.is_level">
  512. </el-switch>
  513. </el-form-item>
  514. <template v-if="ruleForm.is_level == 1">
  515. <el-form-item label="是否单独设置会员价" prop="is_level_alone">
  516. <el-switch :active-value="1" :inactive-value="0" v-model="ruleForm.is_level_alone">
  517. </el-switch>
  518. </el-form-item>
  519. <template v-if="ruleForm.is_level_alone == 1">
  520. <template v-if="ruleForm.use_attr == 1 && memberLevel.length > 0">
  521. <!--多规格会员价设置-->
  522. <el-form-item label="会员价设置">
  523. <com-attr v-model="ruleForm.attr" :attr-groups="attrGroups" :members="memberLevel" :is-level="true"></com-attr>
  524. </el-form-item>
  525. </template>
  526. <!-- 无规格默认会员价 -->
  527. <template v-if="ruleForm.use_attr == 0 && memberLevel.length > 0">
  528. <el-form-item label="默认规格会员价设置">
  529. <el-col :xl="12" :lg="16">
  530. <el-input v-for="item in defaultMemberPrice" :key="item.id" type="number" v-model="ruleForm.member_price[item.level]">
  531. <span slot="prepend">{{item.name}}</span>
  532. <span slot="append">元</span>
  533. </el-input>
  534. </el-col>
  535. </el-form-item>
  536. <el-form-item>
  537. <el-tag type="danger">如需设置多规格会员价,请先添加商品规格</el-tag>
  538. </el-form-item>
  539. </template>
  540. <el-form-item v-if="memberLevel.length == 0" label="会员价设置">
  541. <el-button type="danger" @click="$navigate({r: 'mall/member-level/edit'})">
  542. 如需设置,请先添加会员
  543. </el-button>
  544. </el-form-item>
  545. </template>
  546. </template>
  547. <el-form-item v-if="is_svip" label="是否享受超级会员功能" prop="is_vip_card_goods">
  548. <el-switch v-model="is_vip_card_goods" :active-value="1" :inactive-value="0"></el-switch>
  549. </el-form-item>
  550. </el-tab-pane>
  551. <el-tab-pane label="配送设置" name="third" v-if="is_show_distribution">
  552. <template v-if="goods_id!='0'">
  553. <el-tabs v-model="distributionName" v-if="activeName == 'third'" @tab-click="distributionClick" style="margin-left: 20px;">
  554. <el-tab-pane label="佣金" name="default">
  555. <com-goods-distribution v-if="distributionName=='default'" v-model="ruleForm"
  556. :is_mch="is_mch"
  557. :goods_type="goods_type"
  558. :goods_id="goods_id"
  559. @public-lever-data = "getPublicLeverData">
  560. </com-goods-distribution>
  561. </el-tab-pane>
  562. <template v-if="currencyList.length>0">
  563. <!-- 是否支持商业模式 -->
  564. <el-tab-pane v-if="item.enable_bussiness_mode" v-for="item in currencyList" :key="item.code" :label="item.name" :name="item.code">
  565. <com-goods-currency-distribution
  566. v-if="distributionName==item.code"
  567. :goods_type="goods_type"
  568. :goods_id="goods_id"
  569. :currency_code="item.code"
  570. :item_type="item"
  571. :public_lever_data="publicLeverData">
  572. </com-goods-currency-distribution>
  573. </el-tab-pane>
  574. </template>
  575. </el-tabs>
  576. </template>
  577. </el-tab-pane>
  578. <el-tab-pane label="结算设置" name="fourth" v-if="is_show_agent">
  579. <template v-if="goods_id!='0'">
  580. <el-tabs v-model="distributionName" v-if="activeName == 'fourth'" @tab-click="distributionClick" style="margin-left: 20px;">
  581. <el-tab-pane label="佣金" name="default">
  582. <com-goods-agent v-if="distributionName=='default'" v-model="ruleForm"
  583. :is_mch="is_mch"
  584. :goods_type="goods_type"
  585. :goods_id="goods_id"
  586. >
  587. </com-goods-agent>
  588. </el-tab-pane>
  589. <template v-if="currencyList.length>0">
  590. <el-tab-pane v-if="item.enable_bussiness_mode" v-for="item in currencyList" :key="item.code" :label="item.name" :name="item.code">
  591. <com-goods-currency-agent
  592. v-if="distributionName==item.code"
  593. :goods_type="goods_type"
  594. :goods_id="goods_id"
  595. :currency_code="item.code"
  596. :item_type="item"
  597. >
  598. </com-goods-currency-agent>
  599. </el-tab-pane>
  600. </template>
  601. </el-tabs>
  602. </template>
  603. </el-tab-pane>
  604. </el-tabs>
  605. </el-form>
  606. <choose-user v-model="edit.chooseUser"></choose-user>
  607. <div class="bottom-div" flex="cross:center">
  608. <el-button class="button-item" :loading="btnLoading" type="primary" size="small" @click="store('ruleForm')">保存
  609. </el-button>
  610. <el-button class="button-item" size="small" @click="showPreview">预览</el-button>
  611. </div>
  612. </div>
  613. </el-card>
  614. </template>
  615. <script src="<?= Yii::$app->request->baseUrl ?>/statics/unpkg/vuedraggable@2.18.1/dist/vuedraggable.umd.min.js"></script>
  616. <script>
  617. Vue.component('store', {
  618. template: '#store',
  619. data() {
  620. let ruleForm = {
  621. labels: [],
  622. attr: [],
  623. cats: [],
  624. mchCats: [], //多商户系统分类
  625. cards: [],
  626. services: [],
  627. pic_url: [],
  628. use_attr: 0,
  629. goods_num: 0,
  630. status: 0,
  631. unit: '件',
  632. virtual_sales: 0,
  633. cover_pic: '',
  634. sort: 100,
  635. accumulative: 0,
  636. confine_count: -1,
  637. confine_order_count: -1,
  638. forehead: 0,
  639. forehead_score: 0,
  640. forehead_score_type: 1,
  641. currency_deduct_setting : [], //可代扣货币设置信息
  642. freight_id: 0,
  643. freight: null,
  644. give_score: 0,
  645. give_score_type: 1,
  646. individual_share: 0,
  647. is_level: 1,
  648. is_level_alone: 0,
  649. pieces: 0,
  650. share_type: 0,
  651. attr_setting_type: 0,
  652. video_url: '',
  653. is_sell_well: 0,
  654. is_negotiable: 0,
  655. name: '',
  656. price: 0,
  657. original_price: 0,
  658. cost_price: 0,
  659. detail: '',
  660. extra: '',
  661. app_share_title: '', //自定义分享标题,
  662. app_share_pic: '', //自定义分享图片
  663. is_default_services: 1,
  664. member_price: {},
  665. goods_no: '',
  666. goods_weight: '',
  667. select_attr_groups: [], // 已选择的规格
  668. goodsWarehouse_attrGroups: [], // 商品库商品所有的规格
  669. share_level_type: 0,
  670. distributionLevelList: [],
  671. form: null,
  672. is_show_sales: 0,
  673. use_virtual_sales: 0,
  674. form_id: 0,
  675. attr_default_name: '',
  676. is_area_limit: 0,
  677. use_score: 0,
  678. area_limit: [{
  679. list: []
  680. }],
  681. full_relief_price: 0,
  682. fulfil_price: 0,
  683. // 短视频设置
  684. is_alone: 0, //是否独立
  685. video_share_type: "1", //默认选中百分比
  686. percentage: 0, //默认0%
  687. fixed_value: 0, //默认固定金额0
  688. };
  689. let rules = {
  690. cats: [{
  691. required: true,
  692. type: 'array',
  693. validator: (rule, value, callback) => {
  694. if (this.ruleForm.cats instanceof Array && this.ruleForm.cats.length > 0) {
  695. callback();
  696. }
  697. callback('请选择分类');
  698. }
  699. }],
  700. mchCats: [{
  701. required: true,
  702. type: 'array',
  703. validator: (rule, value, callback) => {
  704. if (this.ruleForm.mchCats instanceof Array && this.ruleForm.mchCats.length > 0) {
  705. callback();
  706. }
  707. callback('请选择系统分类');
  708. }
  709. }],
  710. name: [{
  711. required: true,
  712. message: '请输入商品名称',
  713. trigger: 'change'
  714. }, ],
  715. price: [{
  716. required: true,
  717. message: '请输入商品价格',
  718. trigger: 'change'
  719. }],
  720. original_price: [{
  721. required: true,
  722. message: '请输入商品原价',
  723. trigger: 'change'
  724. }],
  725. cost_price: [{
  726. required: false,
  727. message: '请输入商品成本价',
  728. trigger: 'change'
  729. }],
  730. unit: [{
  731. required: true,
  732. message: '请输入商品单位',
  733. trigger: 'change'
  734. },
  735. {
  736. max: 5,
  737. message: '最大为5个字符',
  738. trigger: 'change'
  739. },
  740. ],
  741. goods_num: [{
  742. required: true,
  743. message: '请输入商品总库存',
  744. trigger: 'change'
  745. }, ],
  746. is_area_limit: [{
  747. required: false,
  748. type: 'integer',
  749. message: '请选择是否开启',
  750. trigger: 'blur'
  751. }],
  752. area_limit: [{
  753. required: true,
  754. type: 'array',
  755. validator: (rule, value, callback) => {
  756. if (value instanceof Array && value[0]['list'].length === 0) {
  757. callback('允许购买区域不能为空');
  758. }
  759. callback();
  760. }
  761. }],
  762. pic_url: [{
  763. required: true,
  764. message: '请上传商品轮播图',
  765. trigger: 'change'
  766. }, ],
  767. };
  768. return {
  769. goods_id: '0',
  770. keyword: '',
  771. goods_type: 'MALL_GOODS',
  772. label_list: [],
  773. cardLoading: false,
  774. btnLoading: false,
  775. dialogLoading: false,
  776. activeName: 'first',
  777. distributionName : 'default', //二级tab默认显示佣金
  778. marketeName : 'default', //营销二级tab默认
  779. ruleForm: ruleForm,
  780. // 分销层级
  781. shareLevel: [],
  782. // 会员等级
  783. memberLevel: [],
  784. rules: rules,
  785. options: [], // 商品分类列表
  786. mchOptions: [], //多商户商品编辑时使用
  787. newOptions: [],
  788. cats: [], //用于前端已选的分类展示
  789. mchCats: [], //用于前端已选的分类展示 多商户
  790. cards: [], // 优惠券
  791. attrGroups: [], //规格组
  792. attrGroupName: '',
  793. attrName: [],
  794. // 批量设置
  795. batch: {},
  796. dialogVisible: false, //分类选择弹框
  797. mchDialogVisible: false,
  798. is_vip_card_goods: 0,
  799. is_svip: false,
  800. goods_warehouse: {},
  801. copyUrl: '',
  802. copyLoading: false,
  803. defaultServiceChecked: false,
  804. service: {
  805. dialog: false,
  806. list: [],
  807. services: [], // 商品服务列表
  808. loading: false
  809. },
  810. freight: {
  811. dialog: false,
  812. list: [],
  813. checked: {},
  814. loading: false
  815. },
  816. copyId: '',
  817. app_share: {
  818. dialog: false,
  819. type: '',
  820. bg: "<?= \Yii::$app->request->baseUrl ?>/statics/img/mall/app-share.png",
  821. name_bg: "<?= \Yii::$app->request->baseUrl ?>/statics/img/mall/app-share-name.png",
  822. pic_bg: "<?= \Yii::$app->request->baseUrl ?>/statics/img/mall/app-share-pic.png",
  823. },
  824. is_show_distribution: 1,
  825. is_show_agent: 1,
  826. is_show_area: 1,
  827. is_show_short_video: 1,
  828. is_show_coupon: 1,
  829. use_score: 0,
  830. video_type: 1,
  831. cardDialogVisible: false,
  832. isEcoupon: false, //默认没有安装电子券插件
  833. currencyList : [], //可用货币列表
  834. publicLeverData : {}, //红包设置公用的等级数据
  835. foundLoading: false,
  836. userList: {},
  837. edit: {
  838. chooseUser: false
  839. }
  840. };
  841. },
  842. created() {
  843. if (getQuery('id')) {
  844. this.getDetail(getQuery('id'));
  845. this.goods_id = getQuery('id');
  846. }
  847. if (this.is_distribution == 1) {
  848. this.getPermissions();
  849. } else {
  850. this.is_show_distribution = 0
  851. }
  852. this.getLabels();
  853. this.getEcoupon();
  854. },
  855. computed: {
  856. cForm() {
  857. let form = {};
  858. let ruleForm = JSON.parse(JSON.stringify(this.ruleForm));
  859. if (this.form) {
  860. form = Object.assign(ruleForm, JSON.parse(JSON.stringify(this.form)));
  861. } else {
  862. form = ruleForm;
  863. }
  864. if (getQuery('id')) {
  865. form.id = getQuery('id')
  866. }
  867. return form;
  868. },
  869. cRule() {
  870. return this.rule ? Object.assign({}, this.rules, this.rule) : this.rules;
  871. },
  872. isConfineCount() {
  873. return this.ruleForm.confine_count === -1;
  874. },
  875. },
  876. filters: {
  877. checkedStatus(status) {
  878. if(this.checkedCities1.indexOf(status) > -1){
  879. return true
  880. }else{
  881. return false;
  882. }
  883. },
  884. },
  885. methods: {
  886. chooseUser() {
  887. this.edit.chooseUser = true;
  888. },
  889. search(){
  890. this.foundLoading = true;
  891. request({
  892. params: {
  893. r: 'plugin/o2o_store/mall/store/search-user',
  894. keyword: this.keyword,
  895. },
  896. }).then(e => {
  897. this.foundLoading = false;
  898. if (e.data.code == 0) {
  899. this.userList = e.data.data.list;
  900. }
  901. }).catch(e => {
  902. this.foundLoading = false;
  903. });
  904. },
  905. // 红包设置-公用的等级数据
  906. getPublicLeverData(msg){
  907. this.publicLeverData = msg;
  908. console.log(this.publicLeverData);
  909. console.log('msg');
  910. },
  911. // 获取获取可用货币,用于商品设置
  912. getEnableCurrency() {
  913. this.loading = true;
  914. // const cacheKey = '_MALL_CURRENCY'; //对应商城可用货币
  915. let params = {
  916. r: 'mall/currency/get-enable-currency'
  917. };
  918. request({
  919. params: params,
  920. method: 'get',
  921. }).then(e => {
  922. this.loading = false;
  923. if (e.data.code == 0) {
  924. this.currencyList = e.data.data;
  925. console.log(this.currencyList);
  926. // console.log('444555');
  927. if(this.currencyList.length && this.currencyList.length>0){
  928. let currency_deduct_setting = [];
  929. this.currencyList.forEach((item, index) => {
  930. let settingItem = {
  931. max_deduction_num : 0, //币种最大抵扣数
  932. give_num : 0, //币种赠送数额
  933. is_percent_give : '1', //是否按百分比赠送
  934. deduction_type : '1', //抵扣类型
  935. }
  936. settingItem['currency_code'] = item.code;
  937. let response_currency_deduct_setting = JSON.parse(JSON.stringify(this.ruleForm.currency_deduct_setting));
  938. // console.log(response_currency_deduct_setting);
  939. if(response_currency_deduct_setting.length && response_currency_deduct_setting.length>0){
  940. response_currency_deduct_setting.forEach((its, ids) => {
  941. if(its.currency_code == item.code){
  942. settingItem = Object.assign(settingItem, its);
  943. }
  944. })
  945. }
  946. currency_deduct_setting.push(settingItem);
  947. })
  948. this.$set(this.ruleForm, 'currency_deduct_setting', currency_deduct_setting);
  949. }
  950. } else {
  951. }
  952. }).catch(e => {
  953. this.loading = false;
  954. });
  955. },
  956. //0.1 getEcoupon-检查是否安装了电子券插件
  957. getEcoupon() {
  958. let self = this;
  959. self.cardLoading = true;
  960. request({
  961. params: {
  962. r: 'mall/plugin/is-install',
  963. plugin_name: 'e_coupon',
  964. },
  965. method: 'get',
  966. }).then(e => {
  967. self.cardLoading = false;
  968. if (e.data.code == 0) {
  969. self.isEcoupon = true;
  970. } else {
  971. self.isEcoupon = false;
  972. }
  973. })
  974. },
  975. getLabels() {
  976. request({
  977. params: {
  978. r: 'mall/goods/label',
  979. },
  980. }).then(e => {
  981. if (e.data.code === 0) {
  982. this.label_list = e.data.data.list;
  983. } else {
  984. }
  985. })
  986. },
  987. showPreview() {
  988. this.$refs.preview.previewGoods();
  989. this.$emit('handle-preview', this.ruleForm);
  990. },
  991. selectCat(cats) {
  992. this.cats = cats;
  993. let arr = [];
  994. cats.map(v => {
  995. arr.push(v.value);
  996. })
  997. this.ruleForm.cats = arr;
  998. this.$refs.ruleForm.validateField('cats');
  999. },
  1000. selectMchCat(cats) {
  1001. this.mchCats = cats;
  1002. let arr = [];
  1003. cats.map(v => {
  1004. arr.push(v.value);
  1005. })
  1006. this.ruleForm.mchCats = arr;
  1007. this.$refs.ruleForm.validateField('mchCats');
  1008. },
  1009. getSvip() {
  1010. request({
  1011. params: {
  1012. r: 'mall/member-level/vip-card-permission',
  1013. plugin: this.sign
  1014. },
  1015. }).then(e => {
  1016. if (e.data.code === 0) {
  1017. this.is_svip = true;
  1018. } else {
  1019. this.is_svip = false;
  1020. }
  1021. })
  1022. },
  1023. delPic(index) {
  1024. this.ruleForm.pic_url.splice(index, 1)
  1025. },
  1026. catDialogCancel() {
  1027. let that = this;
  1028. that.mchDialogVisible = false;
  1029. that.dialogVisible = false;
  1030. that.ruleForm.cats = [];
  1031. that.ruleForm.mchCats = [];
  1032. if (that.cats.length > 0) {
  1033. that.cats.forEach(function(row) {
  1034. that.ruleForm.cats.push(row.value.toString());
  1035. })
  1036. }
  1037. if (that.mchCats.length > 0) {
  1038. that.mchCats.forEach(function(row) {
  1039. that.ruleForm.mchCats.push(row.value.toString());
  1040. })
  1041. }
  1042. },
  1043. getPermissions() {
  1044. let self = this;
  1045. request({
  1046. params: {
  1047. r: 'mall/index/mall-permissions'
  1048. },
  1049. method: 'get',
  1050. }).then(e => {
  1051. if (e.data.code === 0) {
  1052. if(self.admin_type > 1){
  1053. self.is_show_distribution = 0;
  1054. self.is_show_agent = 0;
  1055. self.is_show_area = 0;
  1056. self.is_show_short_video = 0;
  1057. e.data.data.permissions.forEach(function (item) {
  1058. if (item.includes('distribution')){
  1059. self.is_show_distribution = 1;
  1060. }
  1061. if (item.includes('area')){
  1062. self.is_show_area = 1;
  1063. }
  1064. if (item.includes('agent')){
  1065. self.is_show_agent = 1;
  1066. }
  1067. if (item.includes('video')){
  1068. self.is_show_short_video = 1;
  1069. }
  1070. })
  1071. }
  1072. } else {
  1073. self.$message.error(e.data.msg);
  1074. }
  1075. }).catch(e => {
  1076. console.log(e);
  1077. });
  1078. },
  1079. store(formName) {
  1080. let self = this;
  1081. try {
  1082. self.cForm.attr.map(item => {
  1083. if (item.price < 0 || item.price === '') {
  1084. throw new Error('规格价格不能为空');
  1085. }
  1086. if (item.stock < 0 || item.stock === '') {
  1087. throw new Error('库存不能为空');
  1088. }
  1089. })
  1090. } catch (error) {
  1091. self.$message.error(error.message);
  1092. return;
  1093. }
  1094. self.$refs[formName].validate((valid) => {
  1095. if (valid) {
  1096. self.btnLoading = true;
  1097. if (self.is_svip) {
  1098. self.cForm.is_vip_card_goods = self.is_vip_card_goods
  1099. } else {
  1100. delete self.cForm['is_vip_card_goods']
  1101. }
  1102. // 积分设置百分比
  1103. if(self.ruleForm.give_score_type==2 && ((self.ruleForm.give_score*1 < 0) || (self.ruleForm.give_score*1 >100))){
  1104. this.$message.error('积分设置百分比范围为0%~100%');
  1105. return
  1106. }
  1107. // console.log(self.cForm);
  1108. // return
  1109. request({
  1110. params: {
  1111. r: 'plugin/o2o_store/mall/store/edit'
  1112. },
  1113. method: 'post',
  1114. data: {
  1115. form: JSON.stringify(self.cForm),
  1116. attrGroups: JSON.stringify(self.attrGroups),
  1117. }
  1118. }).then(e => {
  1119. self.btnLoading = false;
  1120. if (e.data.code === 0) {
  1121. //保存成功
  1122. self.$message.success(e.data.msg);
  1123. if (typeof this.referrer === 'object') {
  1124. navigateTo(this.referrer)
  1125. } else {
  1126. navigateTo({
  1127. r: this.referrer,
  1128. })
  1129. }
  1130. } else {
  1131. self.$message.error(e.data.msg);
  1132. }
  1133. }).catch(e => {
  1134. console.log(e);
  1135. });
  1136. } else {
  1137. console.log('error submit!!');
  1138. self.$message.error('请填写必填参数');
  1139. return false;
  1140. }
  1141. });
  1142. },
  1143. getDetail(id, url = '') {
  1144. let self = this;
  1145. self.cardLoading = true;
  1146. request({
  1147. params: {
  1148. r: url ? url : this.get_goods_url,
  1149. id: id,
  1150. },
  1151. method: 'get',
  1152. }).then(e => {
  1153. self.cardLoading = false;
  1154. if (e.data.code == 0) {
  1155. let detail = e.data.data.detail;
  1156. if (detail['use_attr'] === 0) {
  1157. detail['attr_groups'] = [];
  1158. }
  1159. if (detail.is_vip_card_goods) {
  1160. self.is_vip_card_goods = detail.is_vip_card_goods
  1161. }
  1162. if (this.form && this.form.extra) {
  1163. for (let i in this.form.extra) {
  1164. if (detail.use_attr == 1) {
  1165. for (let j in detail.attr) {
  1166. if (!detail.attr[j][i]) {
  1167. detail.attr[j][i] = 0;
  1168. }
  1169. }
  1170. }
  1171. Vue.set(self.ruleForm, i, 0);
  1172. }
  1173. }
  1174. self.cats = detail.cats;
  1175. if (detail.cats) {
  1176. let cats = [];
  1177. for (let i in detail.cats) {
  1178. cats.push(detail.cats[i].value.toString());
  1179. }
  1180. detail.cats = cats;
  1181. }
  1182. self.mchCats = detail.mchCats;
  1183. if (detail.mchCats) {
  1184. let mchCats = [];
  1185. for (let i in detail.mchCats) {
  1186. mchCats.push(detail.mchCats[i].value.toString());
  1187. }
  1188. detail.mchCats = mchCats;
  1189. }
  1190. self.ruleForm = Object.assign(self.ruleForm, detail);
  1191. self.attrGroups = e.data.data.detail.attr_groups;
  1192. self.goods_warehouse = e.data.data.detail.goods_warehouse;
  1193. self.defaultServiceChecked = !!parseInt(self.ruleForm.is_default_services);
  1194. //全额积分抵扣
  1195. this.checkFullForeheadScore();
  1196. self.$emit('goods-success', self.ruleForm);
  1197. // 这里可能要构建-营销多货币返显数据
  1198. self.getEnableCurrency(); //获取可用币种
  1199. } else {
  1200. self.$message.error(e.data.msg);
  1201. }
  1202. }).catch(e => {
  1203. self.cardLoading = false;
  1204. console.log(e);
  1205. });
  1206. },
  1207. // 标签页
  1208. handleClick(tab, event) {
  1209. this.$emit('change-tabs', tab.name);
  1210. console.log(tab.name, 'tab.nametab.nametab.name')
  1211. if (tab.name == "third") {
  1212. if (this.goods_id == 0) {
  1213. this.$alert('请先保存商品后重试!', '分销设置提示', {
  1214. confirmButtonText: '确定',
  1215. });
  1216. return;
  1217. }
  1218. this.distributionName = 'default';
  1219. this.getMembers();
  1220. }
  1221. if(tab.name == "fourth" || tab.name == "fifth"){
  1222. // 分销、经销、区域设置二级tab初始化
  1223. this.distributionName = 'default';
  1224. }
  1225. if (tab.name == "seventh") {
  1226. // 请求短视频设置
  1227. this.videoLoadData();
  1228. }
  1229. if (tab.name == "eighth") {
  1230. this.marketeName = 'default';
  1231. // 请求短视频设置
  1232. // this.videoLoadData();
  1233. }
  1234. if (tab.name == "second") {
  1235. // 请求会员价设置
  1236. this.getMembers();
  1237. }
  1238. if (tab.name == "tenth") {
  1239. // 电子券设置
  1240. }
  1241. },
  1242. // 货币设置二级tab点击事件
  1243. distributionClick(tab, event) {
  1244. this.$emit('change-tabs', tab.name);
  1245. console.log(tab.name, 'tab.nametab.nametab.name')
  1246. },
  1247. // 获取商品服务
  1248. getServices() {
  1249. let self = this;
  1250. this.service.loading = true;
  1251. request({
  1252. params: {
  1253. r: 'mall/service/options'
  1254. },
  1255. method: 'get',
  1256. data: {}
  1257. }).then(e => {
  1258. this.service.loading = false;
  1259. if (e.data.code == 0) {
  1260. self.service.services = e.data.data.list;
  1261. } else {
  1262. self.$message.error(e.data.msg);
  1263. }
  1264. }).catch(e => {
  1265. console.log(e);
  1266. });
  1267. },
  1268. // 设置默认服务
  1269. defaultService() {
  1270. if (this.defaultServiceChecked) {
  1271. this.ruleForm.is_default_services = 1;
  1272. this.ruleForm.services = [];
  1273. } else {
  1274. this.ruleForm.is_default_services = 0;
  1275. }
  1276. },
  1277. // 获取会员列表
  1278. getMembers() {
  1279. let self = this;
  1280. self.cardLoading = true;
  1281. request({
  1282. params: {
  1283. r: 'mall/member-level/all-member'
  1284. },
  1285. method: 'get',
  1286. data: {}
  1287. }).then(e => {
  1288. self.cardLoading = false;
  1289. if (e.data.code == 0) {
  1290. self.memberLevel = e.data.data.list;
  1291. let defaultMemberPrice = [];
  1292. // 以下数据用于默认规格情况下的 会员价设置
  1293. self.memberLevel.forEach(function(item, index) {
  1294. let obj = {};
  1295. obj['id'] = index;
  1296. obj['name'] = item.name;
  1297. obj['level'] = 'level' + parseInt(item.level);
  1298. defaultMemberPrice.push(obj);
  1299. });
  1300. self.defaultMemberPrice = defaultMemberPrice;
  1301. } else {
  1302. self.$message.error(e.data.msg);
  1303. }
  1304. }).catch(e => {
  1305. console.log(e);
  1306. });
  1307. },
  1308. // 获取运费规则选项
  1309. getFreight() {
  1310. let self = this;
  1311. this.freight.loading = true;
  1312. request({
  1313. params: {
  1314. r: 'mall/postage-rules/all-list'
  1315. },
  1316. method: 'get',
  1317. data: {}
  1318. }).then(e => {
  1319. this.freight.loading = false;
  1320. if (e.data.code == 0) {
  1321. self.freight.list = e.data.data.list;
  1322. // 添加商品时使用默认运费
  1323. self.freight.list.unshift({
  1324. id: 0,
  1325. name: '默认运费',
  1326. status: 1
  1327. })
  1328. } else {
  1329. self.$message.error(e.data.msg);
  1330. }
  1331. }).catch(e => {
  1332. console.log(e);
  1333. });
  1334. },
  1335. // 规格组合
  1336. makeAttrGroup(e) {
  1337. let self = this;
  1338. let array = [];
  1339. self.attrGroups.forEach(function(attrGroupItem, attrGroupIndex) {
  1340. attrGroupItem.attr_list.forEach(function(attrListItem, attrListIndex) {
  1341. let object = {
  1342. attr_group_id: attrGroupItem.attr_group_id,
  1343. attr_group_name: attrGroupItem.attr_group_name,
  1344. attr_id: attrListItem.attr_id,
  1345. attr_name: attrListItem.attr_name,
  1346. };
  1347. if (!array[attrGroupIndex]) {
  1348. array[attrGroupIndex] = [];
  1349. }
  1350. array[attrGroupIndex].push(object)
  1351. });
  1352. });
  1353. // 2.属性排列组合
  1354. const res = array.reduce((osResult, options) => {
  1355. return options.reduce((oResult, option) => {
  1356. if (!osResult.length) {
  1357. return oResult.concat(option)
  1358. } else {
  1359. return oResult.concat(osResult.map(o => [].concat(o, option)))
  1360. }
  1361. }, [])
  1362. }, []);
  1363. // 3.组合结果赋值
  1364. for (let i in res) {
  1365. const options = Array.isArray(res[i]) ? res[i] : [res[i]];
  1366. const row = {
  1367. attr_list: options,
  1368. stock: 0,
  1369. price: 0,
  1370. no: '',
  1371. weight: 0,
  1372. pic_url: '',
  1373. distributionLevelList: [],
  1374. };
  1375. let extra = {};
  1376. if (this.form && this.form.extra) {
  1377. extra = JSON.parse(JSON.stringify(this.form.extra));
  1378. for (let i in extra) {
  1379. row[i] = 0;
  1380. }
  1381. }
  1382. // 动态绑定多规格会员价
  1383. let obj = {};
  1384. self.memberLevel.forEach(function(memberLevelItem, memberLevelIndex) {
  1385. let key = 'level' + memberLevelItem.level;
  1386. obj[key] = 0;
  1387. });
  1388. row['member_price'] = obj;
  1389. // 3-1.已设置数据的优先使用原数据
  1390. if (self.ruleForm.attr.length) {
  1391. for (let j in self.ruleForm.attr) {
  1392. const oldOptions = [];
  1393. for (let k in self.ruleForm.attr[j].attr_list) {
  1394. oldOptions.push(self.ruleForm.attr[j].attr_list[k].attr_name)
  1395. }
  1396. const newOptions = [];
  1397. for (let k in options) {
  1398. newOptions.push(options[k].attr_name)
  1399. }
  1400. if (oldOptions.toString() === newOptions.toString()) {
  1401. row['price'] = self.ruleForm.attr[j].price;
  1402. row['stock'] = self.ruleForm.attr[j].stock;
  1403. row['no'] = self.ruleForm.attr[j].no;
  1404. row['weight'] = self.ruleForm.attr[j].weight;
  1405. row['pic_url'] = self.ruleForm.attr[j].pic_url;
  1406. break
  1407. }
  1408. }
  1409. }
  1410. res[i] = row;
  1411. }
  1412. self.ruleForm.attr = res;
  1413. },
  1414. // 批量设置
  1415. batchAttr(key) {
  1416. let self = this;
  1417. if (self.batch[key] && self.batch[key] >= 0 || key === 'no') {
  1418. self.ruleForm.attr.forEach(function(item, index) {
  1419. // 批量设置会员价
  1420. // 判断字符串是否出现过,并返回位置
  1421. if (key.indexOf('level') !== -1) {
  1422. item['member_price'][key] = self.batch[key];
  1423. } else {
  1424. item[key] = self.batch[key];
  1425. }
  1426. });
  1427. }
  1428. },
  1429. destroyCat(value, index) {
  1430. let self = this;
  1431. self.ruleForm.cats.splice(self.ruleForm.cats.indexOf(value), 1)
  1432. self.cats.splice(index, 1)
  1433. },
  1434. destroyCat_2(value, index) {
  1435. let self = this;
  1436. self.ruleForm.mchCats.splice(self.ruleForm.mchCats.indexOf(value), 1)
  1437. self.mchCats.splice(index, 1)
  1438. },
  1439. // 商品视频
  1440. videoUrl(e) {
  1441. if (e.length) {
  1442. this.ruleForm.video_url = e[0].url;
  1443. }
  1444. },
  1445. // 短视频设置单选按钮
  1446. shareTypeChange(e) {
  1447. if (e == 0) {
  1448. this.ruleForm.percentage = 0;
  1449. } else {
  1450. this.ruleForm.fixed_value = 0;
  1451. }
  1452. },
  1453. // 4.0 短视频设置
  1454. videoSetting() {
  1455. let self = this;
  1456. let postData = {
  1457. goods_id: self.goods_id,
  1458. video_share_type: self.ruleForm.video_share_type,
  1459. percentage: self.ruleForm.percentage,
  1460. fixed_value: self.ruleForm.fixed_value,
  1461. is_alone: self.ruleForm.is_alone,
  1462. }
  1463. request({
  1464. params: {
  1465. r: 'plugin/short_video/mall/goods/goods-setting',
  1466. },
  1467. method: 'post',
  1468. data: postData
  1469. }).then(e => {
  1470. self.loading = false;
  1471. if (e.data.code == 0) {
  1472. self.$message.success(e.data.msg);
  1473. } else {
  1474. self.$message.error(e.data.msg);
  1475. }
  1476. }).catch(e => {
  1477. console.log(e);
  1478. });
  1479. },
  1480. // 4.1 获取短视频设置
  1481. videoLoadData() {
  1482. let self = this;
  1483. self.loading = true;
  1484. request({
  1485. params: {
  1486. r: 'plugin/short_video/mall/goods/goods-setting',
  1487. goods_id: self.goods_id,
  1488. },
  1489. method: 'get',
  1490. data: {}
  1491. }).then(e => {
  1492. self.loading = false;
  1493. if (e.data.code == 0) {
  1494. // self.form = e.data.data.setting;
  1495. self.ruleForm.is_alone = e.data.data.is_alone;
  1496. self.ruleForm.video_share_type = e.data.data.video_share_type;
  1497. self.ruleForm.percentage = e.data.data.percentage;
  1498. self.ruleForm.fixed_value = e.data.data.fixed_value;
  1499. } else {
  1500. self.$message.error(e.data.msg);
  1501. }
  1502. }).catch(e => {
  1503. console.log(e);
  1504. });
  1505. },
  1506. // 商品轮播图
  1507. picUrl(e) {
  1508. if (e.length) {
  1509. let self = this;
  1510. e.forEach(function(item, index) {
  1511. if (self.ruleForm.pic_url.length >= 9) {
  1512. return;
  1513. }
  1514. self.ruleForm.pic_url.push({
  1515. id: item.id,
  1516. pic_url: item.url
  1517. });
  1518. });
  1519. }
  1520. },
  1521. // 是否开启规格
  1522. checkedAttr(e) {
  1523. if (e == 1) {
  1524. this.attrGroups = [];
  1525. this.ruleForm.goods_num = this.ruleForm.goods_num ? this.ruleForm.goods_num : 0;
  1526. }
  1527. },
  1528. itemChecked(type) {
  1529. this.ruleForm.confine_count = type ? -1 : 0;
  1530. },
  1531. itemOrderChecked(type) {
  1532. this.ruleForm.confine_order_count = type ? -1 : 0;
  1533. },
  1534. selectGoodsWarehouse(goods_warehouse) {
  1535. this.ruleForm.select_attr_groups = [];
  1536. this.getDetail(goods_warehouse.id, 'mall/goods/edit')
  1537. },
  1538. copyGoods() {
  1539. this.copyLoading = true;
  1540. request({
  1541. params: {
  1542. r: 'mall/goods/collect',
  1543. url: this.copyUrl
  1544. },
  1545. method: 'get'
  1546. }).then(e => {
  1547. this.copyLoading = false;
  1548. if (e.data.code === 0) {
  1549. let detail = e.data.data.detail;
  1550. if (this.form && this.form.extra) {
  1551. for (let i in this.form.extra) {
  1552. if (detail.use_attr == 1) {
  1553. for (let j in detail.attr) {
  1554. if (!detail.attr[j][i]) {
  1555. detail.attr[j][i] = 0;
  1556. }
  1557. }
  1558. }
  1559. Vue.set(this.ruleForm, i, 0);
  1560. }
  1561. }
  1562. this.ruleForm = Object.assign(this.ruleForm, detail);
  1563. this.attrGroups = e.data.data.detail.attr_groups;
  1564. this.$message.success(e.data.msg);
  1565. } else {
  1566. this.$message.error(e.data.msg);
  1567. }
  1568. }).catch(e => {
  1569. this.copyLoading = false;
  1570. console.log(e);
  1571. });
  1572. },
  1573. updatePicUrl(e, params) {
  1574. this.ruleForm.pic_url[params.currentIndex].id = e[0].id;
  1575. this.ruleForm.pic_url[params.currentIndex].pic_url = e[0].url;
  1576. },
  1577. getOptionName(name) {
  1578. let newName = name;
  1579. let num = 12;
  1580. if (newName.length > num) {
  1581. newName = newName.substring(0, num) + '...';
  1582. }
  1583. return newName;
  1584. },
  1585. /*---商品服务----*/
  1586. serviceOpen() {
  1587. this.service.dialog = true;
  1588. this.getServices();
  1589. },
  1590. serviceCancel() {
  1591. this.service.dialog = false;
  1592. this.service.list = [];
  1593. },
  1594. serviceConfirm() {
  1595. let self = this;
  1596. let newServices = JSON.parse(JSON.stringify(this.service.list));
  1597. let addServices = [];
  1598. newServices.forEach(function(item, index) {
  1599. let sign = true;
  1600. self.ruleForm.services.forEach(function(item2, index2) {
  1601. if (item.id == item2.id) {
  1602. sign = false;
  1603. }
  1604. })
  1605. if (sign) {
  1606. addServices.push(item)
  1607. }
  1608. });
  1609. this.ruleForm.services = this.ruleForm.services.concat(addServices);
  1610. this.serviceCancel();
  1611. },
  1612. serviceDelete(index) {
  1613. this.ruleForm.services.splice(index, 1);
  1614. },
  1615. /*---运费----*/
  1616. freightOpen() {
  1617. this.freight.dialog = true;
  1618. this.getFreight();
  1619. },
  1620. freightCancel() {
  1621. this.freight.checked = {};
  1622. this.freight.dialog = false;
  1623. },
  1624. freightConfirm() {
  1625. this.ruleForm.freight = JSON.parse(JSON.stringify(this.freight.checked));
  1626. this.ruleForm.freight_id = this.ruleForm.freight.id;
  1627. this.freightCancel();
  1628. },
  1629. freightDelete() {
  1630. this.ruleForm.freight = null;
  1631. this.ruleForm.freight_id = 0;
  1632. },
  1633. cardDelete(index) {
  1634. this.ruleForm.cards.splice(index, 1);
  1635. },
  1636. // 上架状态开关,弹框文字提示
  1637. statusChange(res) {
  1638. if (res && this.status_change_text) {
  1639. this.$alert(this.status_change_text, '提示', {
  1640. confirmButtonText: '确定',
  1641. callback: action => {}
  1642. });
  1643. }
  1644. },
  1645. selectForm(data) {
  1646. this.ruleForm.form = data;
  1647. this.ruleForm.form_id = data ? data.id : -1;
  1648. },
  1649. fullForeheadScore() {
  1650. this.ruleForm.forehead_score = 99999999;
  1651. this.ruleForm.forehead_score_type = 1;
  1652. this.ruleForm.accumulative = this.ruleForm.full_forehead_score;
  1653. if (this.ruleForm.full_forehead_score == 0) {
  1654. this.ruleForm.forehead_score = 0;
  1655. }
  1656. },
  1657. //检查是否积分全额抵扣
  1658. checkFullForeheadScore() {
  1659. if (this.ruleForm.forehead_score == 99999999 &&
  1660. this.ruleForm.accumulative == 1
  1661. ) {
  1662. this.ruleForm.full_forehead_score = 1;
  1663. }
  1664. },
  1665. change(e) {
  1666. this.$forceUpdate();
  1667. }
  1668. }
  1669. });
  1670. </script>