edit.php 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  6. <link href="{__FRAME_PATH}css/font-awesome.min.css" rel="stylesheet">
  7. <link href="{__ADMIN_PATH}plug/umeditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
  8. <script type="text/javascript" src="{__ADMIN_PATH}plug/umeditor/third-party/jquery.min.js"></script>
  9. <script type="text/javascript" src="{__ADMIN_PATH}plug/umeditor/third-party/template.min.js"></script>
  10. <script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/umeditor/umeditor.config.js"></script>
  11. <script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/umeditor/umeditor.min.js"></script>
  12. <script type="text/javascript" src="{__ADMIN_PATH}plug/umeditor/lang/zh-cn/zh-cn.js"></script>
  13. <link rel="stylesheet" href="/static/plug/layui/css/layui.css">
  14. <script src="/static/plug/layui/layui.js"></script>
  15. <script src="{__PLUG_PATH}vue/dist/vue.min.js"></script>
  16. <script src="/static/plug/axios.min.js"></script>
  17. <script src="{__MODULE_PATH}widget/aliyun-oss-sdk-4.4.4.min.js"></script>
  18. <script src="{__MODULE_PATH}widget/cos-js-sdk-v5.min.js"></script>
  19. <script src="{__MODULE_PATH}widget/qiniu-js-sdk-2.5.5.js"></script>
  20. <script src="{__MODULE_PATH}widget/plupload.full.min.js"></script>
  21. <script src="{__MODULE_PATH}widget/videoUpload.js"></script>
  22. <style>
  23. .layui-form-item {
  24. margin-bottom: 0px;
  25. }
  26. .pictrueBox {
  27. display: inline-block !important;
  28. }
  29. .pictrue {
  30. width: 60px;
  31. height: 60px;
  32. border: 1px dotted rgba(0, 0, 0, 0.1);
  33. margin-right: 15px;
  34. display: inline-block;
  35. position: relative;
  36. cursor: pointer;
  37. }
  38. .pictrue img {
  39. width: 100%;
  40. height: 100%;
  41. }
  42. .upLoad {
  43. width: 58px;
  44. height: 58px;
  45. line-height: 58px;
  46. border: 1px dotted rgba(0, 0, 0, 0.1);
  47. border-radius: 4px;
  48. background: rgba(0, 0, 0, 0.02);
  49. cursor: pointer;
  50. display: flex;
  51. justify-content: center;
  52. align-items: center;
  53. }
  54. .rulesBox {
  55. display: flex;
  56. flex-wrap: wrap;
  57. margin-left: 10px;
  58. }
  59. .layui-tab-content {
  60. margin-top: 15px;
  61. }
  62. .ml110 {
  63. margin: 18px 0 4px 110px;
  64. }
  65. .rules {
  66. display: flex;
  67. }
  68. .rules-btn-sm {
  69. height: 30px;
  70. line-height: 30px;
  71. font-size: 12px;
  72. width: 109px;
  73. }
  74. .rules-btn-sm input {
  75. width: 79% !important;
  76. height: 84% !important;
  77. padding: 0 10px;
  78. }
  79. .ml10 {
  80. margin-left: 10px !important;
  81. }
  82. .ml40 {
  83. margin-left: 40px !important;
  84. }
  85. .closes {
  86. position: absolute;
  87. left: 86%;
  88. top: -18%;
  89. }
  90. .red {
  91. color: red;
  92. }
  93. .layui-input-block .layui-video-box{
  94. width: 22%;
  95. height: 180px;
  96. border-radius: 10px;
  97. background-color: #707070;
  98. margin-top: 10px;
  99. position: relative;
  100. overflow: hidden;
  101. }
  102. .layui-input-block .layui-video-box i{
  103. color: #fff;
  104. line-height: 180px;
  105. margin: 0 auto;
  106. width: 50px;
  107. height: 50px;
  108. display: inherit;
  109. font-size: 50px;
  110. }
  111. .layui-input-block .layui-video-box .mark{
  112. position: absolute;
  113. width: 100%;
  114. height: 30px;
  115. top: 0;
  116. background-color: rgba(0,0,0,.5);
  117. text-align: center;
  118. }
  119. .store_box{
  120. display: flex;
  121. }
  122. .info{
  123. color: #c9c9c9;
  124. padding-left: 10px;
  125. line-height: 30px;
  126. }
  127. </style>
  128. </head>
  129. <body>
  130. <div class="layui-fluid">
  131. <div class="layui-row layui-col-space15" id="app" v-cloak="">
  132. <div class="layui-card">
  133. <div class="layui-card-header">
  134. <span class="">竞拍添加</span>
  135. <button style="margin-left: 20px" type="button" class="layui-btn layui-btn-primary layui-btn-xs" @click="goBack">返回列表</button>
  136. </div>
  137. <div class="layui-card-body">
  138. <form class="layui-form" action="" v-cloak="">
  139. <div class="layui-tab layui-tab-brief" lay-filter="docTabBrief">
  140. <div class="layui-tab-content">
  141. <div class="layui-tab-item layui-show">
  142. <div class="layui-row layui-col-space15">
  143. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  144. <div class="grid-demo grid-demo-bg1">
  145. <div class="layui-form-item">
  146. <label class="layui-form-label">商品名称<i class="red">*</i></label>
  147. <div class="layui-input-block">
  148. <input type="text" name="name" lay-verify="title" autocomplete="off"
  149. placeholder="场馆名称" class="layui-input" v-model="formData.name" maxlength="100">
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  155. <div class="grid-demo grid-demo-bg1">
  156. <div class="layui-form-item">
  157. <label class="layui-form-label">商品图片<i class="red">*</i></label>
  158. <div class="pictrueBox">
  159. <div class="pictrue" v-if="formData.image" @click="uploadImage('image')">
  160. <img :src="formData.image"></div>
  161. <div class="upLoad" @click="uploadImage('image')" v-else>
  162. <i class="layui-icon layui-icon-camera" class="iconfont"
  163. style="font-size: 26px;"></i>
  164. </div>
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  170. <div class="grid-demo grid-demo-bg1">
  171. <div class="layui-form-item">
  172. <label class="layui-form-label">商品轮播图<i class="red">*</i></label>
  173. <div class="pictrueBox pictrue" v-for="(item,index) in formData.slider_image">
  174. <img :src="item">
  175. <i class="layui-icon closes" @click="deleteImage('slider_image',index)">&#x1007</i>
  176. </div>
  177. <div class="pictrueBox">
  178. <div class="upLoad" @click="uploadImage('slider_image')"
  179. v-if="formData.slider_image.length <= rule.slider_image.maxLength">
  180. <i class="layui-icon layui-icon-camera" class="iconfont"
  181. style="font-size: 26px;"></i>
  182. </div>
  183. </div>
  184. </div>
  185. </div>
  186. </div>
  187. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  188. <div class="grid-demo grid-demo-bg1">
  189. <div class="layui-form-item">
  190. <label class="layui-form-label">价格<i class="red">*</i></label>
  191. <div class="layui-input-inline">
  192. <input type="number" name="price" lay-verify="title" autocomplete="off" class="layui-input" v-model="formData.price" maxlength="100" value="0">
  193. </div>
  194. </div>
  195. </div>
  196. </div>
  197. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  198. <div class="grid-demo grid-demo-bg1">
  199. <div class="layui-form-item">
  200. <label class="layui-form-label">挂售价格<i class="red">*</i></label>
  201. <div class="layui-input-inline">
  202. <input type="number" name="hanging_price" lay-verify="title" autocomplete="off" class="layui-input" v-model="formData.hanging_price" maxlength="100" value="0">
  203. </div>
  204. </div>
  205. </div>
  206. </div>
  207. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  208. <div class="grid-demo grid-demo-bg1">
  209. <div class="layui-form-item layui-form-text">
  210. <label class="layui-form-label">商品介绍</label>
  211. <div class="layui-input-block">
  212. <textarea name="info" v-model="formData.info"
  213. placeholder="请输入商品简介" class="layui-textarea"></textarea>
  214. </div>
  215. </div>
  216. </div>
  217. </div>
  218. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  219. <div class="grid-demo grid-demo-bg1">
  220. <div class="layui-form-item">
  221. <label class="layui-form-label">排序</label>
  222. <div class="layui-input-inline">
  223. <input type="number" name="sort" lay-verify="title" autocomplete="off" class="layui-input" v-model="formData.sort" maxlength="100" value="0">
  224. </div>
  225. </div>
  226. </div>
  227. </div>
  228. <label class="layui-form-label" style="left: +1%">商品详情:</label>
  229. <div class="layui-row layui-col-space15">
  230. <textarea type="text/plain" name="description" id="myEditor" style="width:100%;">{{formData.description}}</textarea>
  231. </div>
  232. </div>
  233. </div>
  234. <div class="layui-tab-content">
  235. <div class="layui-row layui-col-space15">
  236. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  237. <button class="layui-btn layui-btn-normal layui-btn-sm" id="submit" type="button" @click="handleSubmit()">提交</button>
  238. </div>
  239. </div>
  240. </div>
  241. </div>
  242. </form>
  243. </div>
  244. </div>
  245. </div>
  246. </div>
  247. <script>
  248. var id = {$id};
  249. var auction_id = {$auction_id};
  250. layui.use('laydate', function(){
  251. var laydate = layui.laydate;
  252. laydate.render({
  253. elem: '#time'
  254. ,type: 'time'
  255. ,range: true
  256. });
  257. laydate.render({
  258. elem: '#rtime'
  259. ,type: 'time'
  260. ,range: true
  261. });
  262. })
  263. new Vue({
  264. el: '#app',
  265. data: {
  266. id:id,
  267. //分类列表
  268. cateList: [],
  269. //运费模板
  270. tempList: [],
  271. upload:{
  272. videoIng:false
  273. },
  274. formData: {
  275. description: '',
  276. name: '',
  277. is_show:1,
  278. image:'',
  279. price:'',
  280. info: '',
  281. sort: 0,
  282. hanging_price: '',
  283. slider_image: [],
  284. auction_id:id,
  285. pl:0
  286. },
  287. rule: { //多图选择规则
  288. slider_image: {
  289. maxLength: 5
  290. }
  291. },
  292. attr: [],//临时属性
  293. newRule: false,//是否添加新规则
  294. radioRule: ['status'],//radio 当选规则
  295. ruleList:[],
  296. ruleIndex:-1,
  297. progress: 0,
  298. um: null,//编译器实例化
  299. form: null,//layui.form
  300. layTabId: 1,
  301. ruleBool: id ? true : false,
  302. },
  303. watch:{
  304. 'formData.is_sub':function (n) {
  305. if (n == 1) {
  306. this.formHeader.push({title:'一级返佣(元)'});
  307. this.formHeader.push({title:'二级级返佣(元)'});
  308. } else {
  309. this.formHeader.pop();
  310. this.formHeader.pop();
  311. }
  312. },
  313. 'formData.spec_type':function (n) {
  314. if (n) {
  315. this.render();
  316. }
  317. },
  318. // 'formData.image':function (n) {
  319. // if(!this.batchAttr.pic){
  320. // this.batchAttr.pic = n;
  321. // }
  322. // if(!this.formData.attr.pic){
  323. // this.formData.attr.pic = n;
  324. // }
  325. // }
  326. },
  327. methods: {
  328. back:function(){
  329. var that = this;
  330. layui.use(['element'], function () {
  331. layui.element.tabChange('docTabBrief', that.layTabId == 1 ? 1 : parseInt(that.layTabId) - 1);
  332. });
  333. },
  334. next:function(){
  335. var that = this;
  336. layui.use(['element'], function () {
  337. layui.element.tabChange('docTabBrief', that.layTabId == 3 ? 3 : parseInt(that.layTabId) + 1);
  338. });
  339. },
  340. goBack:function(){
  341. location.href = this.U({c:'auction.auction_product',a:'index?id='+auction_id});
  342. },
  343. U: function (opt) {
  344. var m = opt.m || 'admin', c = opt.c || window.controlle || '', a = opt.a || 'index', q = opt.q || '',
  345. p = opt.p || {};
  346. var params = Object. keys(p).map(function (key) {
  347. return key + '/' + p[key];
  348. }).join('/');
  349. var gets = Object.keys(q).map(function (key) {
  350. return key+'='+ q[key];
  351. }).join('&');
  352. return '/' + m + '/' + c + '/' + a + (params == '' ? '' : '/' + params) + (gets == '' ? '' : '?' + gets);
  353. },
  354. /**
  355. * 提示
  356. * */
  357. showMsg: function (msg, success) {
  358. $('#submit').removeAttr('disabled').text('提交');
  359. layui.use(['layer'], function () {
  360. layui.layer.msg(msg, success);
  361. });
  362. },
  363. addBrokerage:function(){
  364. if (this.brokerage.brokerage >= 0 && this.brokerage.brokerage_two >= 0){
  365. var that = this;
  366. this.$set(this.formData,'attrs',this.formData.attrs.map(function (item) {
  367. item.brokerage = that.brokerage.brokerage;
  368. item.brokerage_two = that.brokerage.brokerage_two;
  369. return item;
  370. }));
  371. } else {
  372. return this.showMsg('请填写返佣金额在进行批量添加');
  373. }
  374. },
  375. batchClear:function(){
  376. this.$set(this,'batchAttr',{
  377. pic: '',
  378. price: 0,
  379. cost: 0,
  380. ot_price: 0,
  381. stock: 0,
  382. bar_code: '',
  383. weight: 0,
  384. volume: 0,
  385. });
  386. },
  387. /**
  388. * 批量添加
  389. * */
  390. batchAdd:function(){
  391. var that = this;
  392. this.$set(this.formData,'attrs',this.formData.attrs.map(function (item) {
  393. if (that.batchAttr.pic) {
  394. item.pic = that.batchAttr.pic;
  395. }
  396. if (that.batchAttr.price > 0){
  397. item.price = that.batchAttr.price;
  398. }
  399. if (that.batchAttr.cost > 0){
  400. item.cost = that.batchAttr.cost;
  401. }
  402. if (that.batchAttr.ot_price > 0){
  403. item.ot_price = that.batchAttr.ot_price;
  404. }
  405. if (that.batchAttr.stock > 0){
  406. item.stock = that.batchAttr.stock;
  407. }
  408. if (that.batchAttr.bar_code != ''){
  409. item.bar_code = that.batchAttr.bar_code;
  410. }
  411. if (that.batchAttr.weight > 0){
  412. item.weight = that.batchAttr.weight;
  413. }
  414. if (that.batchAttr.volume > 0){
  415. item.volume = that.batchAttr.volume;
  416. }
  417. return item;
  418. }));
  419. },
  420. /**
  421. * 获取商品信息
  422. * */
  423. getProductInfo: function () {
  424. var that = this;
  425. that.requestGet(that.U({c:"auction.auction_product",a:'get_list',q:{id:that.id}})).then(function (res) {
  426. var productInfo = res.data.productInfo || {};
  427. if(productInfo.id && that.id){
  428. that.$set(that,'formData',productInfo);
  429. that.generate();
  430. }
  431. that.getRuleList();
  432. that.init();
  433. }).catch(function (res) {
  434. that.showMsg(res.msg);
  435. })
  436. },
  437. /**
  438. * 给某个属性添加属性值
  439. * @param item
  440. * */
  441. addDetail: function (item) {
  442. if (!item.detailValue) return false;
  443. if (item.detail.find(function (val) {
  444. if(item.detailValue == val){
  445. return true;
  446. }
  447. })) {
  448. return this.showMsg('添加的属性值重复');
  449. }
  450. item.detail.push(item.detailValue);
  451. item.detailValue = '';
  452. },
  453. /**
  454. * 删除某个属性值
  455. * @param item 父级循环集合
  456. * @param inx 子集index
  457. * */
  458. deleteValue: function (item, inx) {
  459. if (item.detail.length > 1) {
  460. item.detail.splice(inx, 1);
  461. } else {
  462. return this.showMsg('请设置至少一个属性');
  463. }
  464. },
  465. /**
  466. * 删除某条属性
  467. * @param index
  468. * */
  469. deleteItem: function (index) {
  470. this.formData.items.splice(index, 1);
  471. },
  472. /**
  473. * 删除某条属性
  474. * @param index
  475. * */
  476. deleteAttrs: function (index) {
  477. var that = this;
  478. if(that.id > 0){
  479. that.requestGet(that.U({c:"store.StoreProduct",a:'check_activity',q:{id:that.id}})).then(function (res) {
  480. that.showMsg(res.msg);
  481. }).catch(function (res) {
  482. if (that.formData.attrs.length > 1) {
  483. that.formData.attrs.splice(index, 1);
  484. } else {
  485. return that.showMsg('请设置至少一个规则');
  486. }
  487. })
  488. }else{
  489. if (that.formData.attrs.length > 1) {
  490. that.formData.attrs.splice(index, 1);
  491. } else {
  492. return that.showMsg('请设置至少一个规则');
  493. }
  494. }
  495. },
  496. /**
  497. * 创建属性
  498. * */
  499. createAttrName: function () {
  500. if (this.formDynamic.attrsName && this.formDynamic.attrsVal) {
  501. if (this.formData.items.find(function (val) {
  502. if (val.value == this.formDynamic.attrsName) {
  503. return true;
  504. }
  505. }.bind(this))) {
  506. return this.showMsg('添加的属性重复');
  507. }
  508. this.formData.items.push({
  509. value: this.formDynamic.attrsName,
  510. detailValue: '',
  511. attrHidden: false,
  512. detail: [this.formDynamic.attrsVal]
  513. });
  514. this.formDynamic.attrsName = '';
  515. this.formDynamic.attrsVal = '';
  516. this.newRule = false;
  517. } else {
  518. return this.showMsg('请添加完整的规格!');
  519. }
  520. },
  521. /**
  522. * 删除图片
  523. * */
  524. deleteImage: function (key, index) {
  525. var that = this;
  526. if (index != undefined) {
  527. that.formData[key].splice(index, 1);
  528. that.$set(that.formData, key, that.formData[key]);
  529. } else {
  530. that.$set(that.formData, key, '');
  531. }
  532. },
  533. createFrame: function (title, src, opt) {
  534. opt === undefined && (opt = {});
  535. var h = 0;
  536. if (window.innerHeight < 800 && window.innerHeight >= 700) {
  537. h = window.innerHeight - 50;
  538. } else if (window.innerHeight < 900 && window.innerHeight >= 800) {
  539. h = window.innerHeight - 100;
  540. } else if (window.innerHeight < 1000 && window.innerHeight >= 900) {
  541. h = window.innerHeight - 150;
  542. } else if (window.innerHeight >= 1000) {
  543. h = window.innerHeight - 200;
  544. } else {
  545. h = window.innerHeight;
  546. }
  547. var area = [(opt.w || window.innerWidth / 2) + 'px', (!opt.h || opt.h > h ? h : opt.h) + 'px'];
  548. layui.use('layer',function () {
  549. return layer.open({
  550. type: 2,
  551. title: title,
  552. area: area,
  553. fixed: false, //不固定
  554. maxmin: true,
  555. moveOut: false,//true 可以拖出窗外 false 只能在窗内拖
  556. anim: 5,//出场动画 isOutAnim bool 关闭动画
  557. offset: 'auto',//['100px','100px'],//'auto',//初始位置 ['100px','100px'] t[ 上 左]
  558. shade: 0,//遮罩
  559. resize: true,//是否允许拉伸
  560. content: src,//内容
  561. move: '.layui-layer-title'
  562. });
  563. });
  564. },
  565. changeIMG: function (name, value) {
  566. if (this.getRule(name).maxLength !== undefined) {
  567. var that = this;
  568. value.map(function (v) {
  569. that.formData[name].push(v);
  570. });
  571. this.$set(this.formData, name, this.formData[name]);
  572. } else {
  573. if(name == 'batchAttr.pic'){
  574. this.batchAttr.pic = value;
  575. } else {
  576. if (name.indexOf('.') !== -1) {
  577. var key = name.split('.');
  578. if (key.length == 2){
  579. this.formData[key[0]][key[1]] = value;
  580. } else if(key.length == 3){
  581. this.formData[key[0]][key[1]][key[2]] = value;
  582. } else if(key.length == 4){
  583. this.$set(this.formData[key[0]][key[1]][key[2]],key[3],value)
  584. }
  585. } else {
  586. this.formData[name] = value;
  587. }
  588. }
  589. }
  590. },
  591. getRule: function (name) {
  592. return this.rule[name] || {};
  593. },
  594. uploadImage: function (name) {
  595. return this.createFrame('选择图片',this.U({c:"widget.images",a:'index',p:{fodder:name}}),{h:545,w:900});
  596. },
  597. uploadVideo: function () {
  598. if (this.videoLink) {
  599. this.formData.video_link = this.videoLink;
  600. } else {
  601. $(this.$refs.filElem).click();
  602. }
  603. },
  604. delVideo: function () {
  605. var that = this;
  606. that.$set(that.formData, 'video_link', '');
  607. },
  608. insertEditor: function (list) {
  609. this.um.execCommand('insertimage', list);
  610. },
  611. insertEditorVideo: function (src) {
  612. this.um.setContent('<div><video style="width: 99%" src="'+src+'" class="video-ue" controls="controls" width="100"><source src="'+src+'"></source></video></div><br>',true);
  613. },
  614. getContent: function () {
  615. return this.um.getContent();
  616. },
  617. /**
  618. * 监听radio字段
  619. */
  620. eeventRadio: function () {
  621. var that = this;
  622. that.radioRule.map(function (val) {
  623. that.form.on('radio(' + val + ')', function (res) {
  624. that.formData[val] = res.value;
  625. });
  626. })
  627. },
  628. init: function () {
  629. var that = this;
  630. window.UMEDITOR_CONFIG.toolbar = [
  631. // 加入一个 test
  632. 'source | undo redo | bold italic underline strikethrough | superscript subscript | forecolor backcolor | removeformat |',
  633. 'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontfamily fontsize',
  634. '| justifyleft justifycenter justifyright justifyjustify |',
  635. 'link unlink | emotion selectimgs video | map',
  636. '| horizontal print preview fullscreen', 'drafts', 'formula'
  637. ];
  638. UM.registerUI('selectimgs', function (name) {
  639. var me = this;
  640. var $btn = $.eduibutton({
  641. icon: 'image',
  642. click: function () {
  643. that.createFrame('选择图片', "{:Url('widget.images/index',['fodder'=>'editor'])}");
  644. },
  645. title: '选择图片'
  646. });
  647. this.addListener('selectionchange', function () {
  648. //切换为不可编辑时,把自己变灰
  649. var state = this.queryCommandState(name);
  650. $btn.edui().disabled(state == -1).active(state == 1)
  651. });
  652. return $btn;
  653. });
  654. UM.registerUI('video', function (name) {
  655. var me = this;
  656. var $btn = $.eduibutton({
  657. icon: 'video',
  658. click: function () {
  659. that.createFrame('选择视频', "{:Url('widget.video/index',['fodder'=>'video'])}");
  660. },
  661. title: '选择视频'
  662. });
  663. this.addListener('selectionchange', function () {
  664. //切换为不可编辑时,把自己变灰
  665. var state = this.queryCommandState(name);
  666. $btn.edui().disabled(state == -1).active(state == 1)
  667. });
  668. return $btn;
  669. });
  670. //实例化编辑器
  671. this.um = UM.getEditor('myEditor', {initialFrameWidth: '99%', initialFrameHeight: 400});
  672. this.um.setContent(that.formData.description);
  673. that.$nextTick(function () {
  674. layui.use(['form','element'], function () {
  675. that.form = layui.form;
  676. that.form.render();
  677. that.form.on('select(temp_id)', function (data) {
  678. that.$set(that.formData, 'temp_id', data.value);
  679. });
  680. that.form.on('select(rule_index)', function (data) {
  681. that.ruleIndex = data.value;
  682. });
  683. layui.element.on('tab(docTabBrief)', function(){
  684. that.layTabId = this.getAttribute('lay-id');
  685. });
  686. that.eeventRadio();
  687. });
  688. })
  689. },
  690. requestPost: function (url, data) {
  691. return new Promise(function (resolve, reject) {
  692. axios.post(url, data).then(function (res) {
  693. if (res.status == 200 && res.data.code == 200) {
  694. resolve(res.data)
  695. } else {
  696. reject(res.data);
  697. }
  698. }).catch(function (err) {
  699. reject({msg:err})
  700. });
  701. })
  702. },
  703. requestGet: function (url) {
  704. return new Promise(function (resolve, reject) {
  705. axios.get(url).then(function (res) {
  706. if (res.status == 200 && res.data.code == 200) {
  707. resolve(res.data)
  708. } else {
  709. reject(res.data);
  710. }
  711. }).catch(function (err) {
  712. reject({msg:err})
  713. });
  714. })
  715. },
  716. generates: function () {
  717. var that = this;
  718. that.generate(1);
  719. },
  720. generate: function (type = 0) {
  721. var that = this;
  722. this.requestPost(that.U({c:"store.StoreProduct",a:'is_format_attr',p:{id:that.id,type:type}}), {attrs:this.formData.items}).then(function (res) {
  723. that.$set(that.formData, 'attrs', res.data.value);
  724. that.$set(that, 'formHeader', res.data.header);
  725. if (that.id && that.formData.is_sub == 1 && that.formData.spec_type == 1) {
  726. that.formHeader.push({title:'一级返佣(元)'});
  727. that.formHeader.push({title:'二级级返佣(元)'});
  728. }
  729. }).catch(function (res) {
  730. return that.showMsg(res.msg);
  731. });
  732. },
  733. handleSubmit:function () {
  734. var that = this;
  735. if (that.formData.name === ''){
  736. return that.showMsg('请输入商品名称');
  737. }
  738. if (that.formData.image === ''){
  739. return that.showMsg('请输入上传图片');
  740. }
  741. if (that.formData.image === ''){
  742. return that.showMsg('请输入上传轮播图');
  743. }
  744. if (that.formData.price <= 0){
  745. return that.showMsg('请输入成本价');
  746. }
  747. if (that.formData.hanging_price <= 0){
  748. return that.showMsg('请输入挂售价');
  749. }
  750. that.formData.description = that.getContent();
  751. that.requestPost(that.U({c:'auction.auctionProduct',a:'update',p:{id:that.id}}),that.formData).then(function (res) {
  752. that.confirm();
  753. }).catch(function (res) {
  754. that.showMsg(res.msg);
  755. });
  756. },
  757. confirm: function(){
  758. var that = this;
  759. layui.use(['layer'], function () {
  760. var layer = layui.layer;
  761. layer.confirm(that.id ? '修改成功是否返回产品列表' : '添加成功是否返回产品列表', {
  762. btn: ['返回列表',that.id ? '继续修改' : '继续添加'] //按钮
  763. }, function(){
  764. location.href = that.U({c:'auction.auction_product',a:'index?id='+auction_id});
  765. }, function(){
  766. location.reload();
  767. });
  768. });
  769. },
  770. render:function(){
  771. this.$nextTick(function(){
  772. layui.use(['form'], function () {
  773. layui.form.render('select');
  774. });
  775. })
  776. },
  777. // 移动
  778. handleDragStart (e, item) {
  779. this.dragging = item;
  780. },
  781. handleDragEnd (e, item) {
  782. this.dragging = null
  783. },
  784. handleDragOver (e) {
  785. e.dataTransfer.dropEffect = 'move'
  786. },
  787. handleDragEnter (e, item) {
  788. e.dataTransfer.effectAllowed = 'move'
  789. if (item === this.dragging) {
  790. return
  791. }
  792. var newItems = [...this.formData.activity];
  793. var src = newItems.indexOf(this.dragging);
  794. var dst = newItems.indexOf(item);
  795. newItems.splice(dst, 0, ...newItems.splice(src, 1))
  796. this.formData.activity = newItems;
  797. },
  798. getRuleList:function (type) {
  799. var that = this;
  800. that.requestGet(that.U({c:'store.StoreProduct',a:'get_rule'})).then(function (res) {
  801. that.$set(that,'ruleList',res.data);
  802. if(type !== undefined){
  803. that.render();
  804. }
  805. });
  806. },
  807. addRule:function(){
  808. return this.createFrame('添加商品规则',this.U({c:'store.StoreProductRule',a:'create'}));
  809. },
  810. allRule:function () {
  811. if (this.ruleIndex != -1) {
  812. var rule = this.ruleList[this.ruleIndex];
  813. if (rule) {
  814. this.ruleBool = true;
  815. var rule_value = rule.rule_value.map(function (item) {
  816. return item;
  817. });
  818. this.$set(this.formData,'items',rule_value);
  819. this.$set(this.formData,'attrs',[]);
  820. this.$set(this,'formHeader',[]);
  821. return true;
  822. }
  823. }
  824. this.showMsg('选择的属性无效');
  825. }
  826. },
  827. mounted: function () {
  828. var that = this;
  829. axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  830. that.getProductInfo();
  831. window.$vm = that;
  832. window.changeIMG = that.changeIMG;
  833. window.insertEditor = that.insertEditor;
  834. window.insertEditorVideo = that.insertEditorVideo;
  835. window.successFun = function(){
  836. that.getRuleList(1);
  837. }
  838. $(that.$refs.filElem).change(function () {
  839. var inputFile = this.files[0];
  840. that.requestPost(that.U({c:"widget.video",a:'get_signature'})).then(function (res) {
  841. AdminUpload.upload(res.data.uploadType,{
  842. token: res.data.uploadToken || '',
  843. file: inputFile,
  844. accessKeyId: res.data.accessKey || '',
  845. accessKeySecret: res.data.secretKey || '',
  846. bucketName: res.data.storageName || '',
  847. region: res.data.storageRegion || '',
  848. domain: res.data.domain || '',
  849. uploadIng:function (progress) {
  850. that.upload.videoIng = true;
  851. that.progress = progress;
  852. }
  853. }).then(function (res) {
  854. //成功
  855. that.$set(that.formData, 'video_link', res.url);
  856. that.progress = 0;
  857. that.upload.videoIng = false;
  858. return that.showMsg('上传成功');
  859. }).catch(function (err) {
  860. //失败
  861. console.info(err);
  862. return that.showMsg('上传错误请检查您的配置');
  863. });
  864. }).catch(function (res) {
  865. return that.showMsg(res.msg || '获取密钥失败,请检查您的配置');
  866. });
  867. })
  868. }
  869. });
  870. </script>
  871. </body>
  872. </html>
  873. <script>
  874. import Layout from "../../../../../public/static/plug/iview/dist/iview";
  875. export default {
  876. components: {Layout}
  877. }
  878. </script>