create.php 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917
  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="nickname" lay-verify="title" autocomplete="off"
  149. placeholder="竞拍名称" class="layui-input" v-model="formData.nickname" 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-row layui-col-space15">
  170. <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
  171. <div class="grid-demo grid-demo-bg1">
  172. <div class="layui-form-item">
  173. <label class="layui-form-label">商品状态</label>
  174. <div class="layui-input-block">
  175. <input type="radio" name="status" lay-filter="status" value="1" title="上架"
  176. :checked="formData.status == 1 ? true : false">
  177. <input type="radio" name="status" lay-filter="status" value="0" title="下架"
  178. :checked="formData.status == 0 ? true : false">
  179. </div>
  180. </div>
  181. </div>
  182. </div>
  183. </div>
  184. <div class="layui-row layui-col-space15">
  185. <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
  186. <div class="grid-demo grid-demo-bg1">
  187. <div class="layui-form-item">
  188. <label class="layui-form-label">预约时间<i class="red ">*</i></label>
  189. <div class="layui-input-inline">
  190. <input type="text" class="layui-input" name="time" id="time" value="" placeholder="-">
  191. </div>
  192. </div>
  193. </div>
  194. </div>
  195. </div>
  196. <div class="layui-row layui-col-space15">
  197. <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
  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="text" class="layui-input" name="rtime" id="rtime" value="" placeholder="-">
  203. </div>
  204. </div>
  205. </div>
  206. </div>
  207. </div>
  208. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  209. <div class="grid-demo grid-demo-bg1">
  210. <div class="layui-form-item">
  211. <label class="layui-form-label">排序<i class="red">*</i></label>
  212. <div class="layui-input-inline">
  213. <input type="number" name="sort" lay-verify="title" autocomplete="off" class="layui-input" v-model="formData.sort" maxlength="100" value="0">
  214. </div>
  215. </div>
  216. </div>
  217. </div>
  218. </div>
  219. <div class="layui-tab-item">
  220. <div class="layui-row layui-col-space15">
  221. <textarea type="text/plain" name="description" id="myEditor" style="width:100%;">{{formData.description}}</textarea>
  222. </div>
  223. </div>
  224. </div>
  225. <div class="layui-tab-content">
  226. <div class="layui-row layui-col-space15">
  227. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  228. <button class="layui-btn layui-btn-normal layui-btn-sm" id="submit" type="button" @click="handleSubmit()">提交</button>
  229. </div>
  230. </div>
  231. </div>
  232. </div>
  233. </form>
  234. </div>
  235. </div>
  236. </div>
  237. </div>
  238. <script>
  239. var id = {$id};
  240. layui.use('laydate', function(){
  241. var laydate = layui.laydate;
  242. laydate.render({
  243. elem: '#time'
  244. ,type: 'time'
  245. ,range: true
  246. });
  247. laydate.render({
  248. elem: '#rtime'
  249. ,type: 'time'
  250. ,range: true
  251. });
  252. })
  253. new Vue({
  254. el: '#app',
  255. data: {
  256. id:id,
  257. //分类列表
  258. cateList: [],
  259. //运费模板
  260. tempList: [],
  261. upload:{
  262. videoIng:false
  263. },
  264. formData: {
  265. description: '',
  266. status: '',
  267. image:'',
  268. time:'',
  269. rtime:''
  270. },
  271. rule: { //多图选择规则
  272. slider_image: {
  273. maxLength: 1
  274. }
  275. },
  276. attr: [],//临时属性
  277. newRule: false,//是否添加新规则
  278. radioRule: ['status'],//radio 当选规则
  279. ruleList:[],
  280. ruleIndex:-1,
  281. progress: 0,
  282. um: null,//编译器实例化
  283. form: null,//layui.form
  284. layTabId: 1,
  285. ruleBool: id ? true : false,
  286. },
  287. watch:{
  288. 'formData.is_sub':function (n) {
  289. if (n == 1) {
  290. this.formHeader.push({title:'一级返佣(元)'});
  291. this.formHeader.push({title:'二级级返佣(元)'});
  292. } else {
  293. this.formHeader.pop();
  294. this.formHeader.pop();
  295. }
  296. },
  297. 'formData.spec_type':function (n) {
  298. if (n) {
  299. this.render();
  300. }
  301. },
  302. // 'formData.image':function (n) {
  303. // if(!this.batchAttr.pic){
  304. // this.batchAttr.pic = n;
  305. // }
  306. // if(!this.formData.attr.pic){
  307. // this.formData.attr.pic = n;
  308. // }
  309. // }
  310. },
  311. methods: {
  312. back:function(){
  313. var that = this;
  314. layui.use(['element'], function () {
  315. layui.element.tabChange('docTabBrief', that.layTabId == 1 ? 1 : parseInt(that.layTabId) - 1);
  316. });
  317. },
  318. next:function(){
  319. var that = this;
  320. layui.use(['element'], function () {
  321. layui.element.tabChange('docTabBrief', that.layTabId == 3 ? 3 : parseInt(that.layTabId) + 1);
  322. });
  323. },
  324. goBack:function(){
  325. location.href = this.U({c:'auction.auction',a:'index'});
  326. },
  327. U: function (opt) {
  328. var m = opt.m || 'admin', c = opt.c || window.controlle || '', a = opt.a || 'index', q = opt.q || '',
  329. p = opt.p || {};
  330. var params = Object. keys(p).map(function (key) {
  331. return key + '/' + p[key];
  332. }).join('/');
  333. var gets = Object.keys(q).map(function (key) {
  334. return key+'='+ q[key];
  335. }).join('&');
  336. return '/' + m + '/' + c + '/' + a + (params == '' ? '' : '/' + params) + (gets == '' ? '' : '?' + gets);
  337. },
  338. /**
  339. * 提示
  340. * */
  341. showMsg: function (msg, success) {
  342. $('#submit').removeAttr('disabled').text('提交');
  343. layui.use(['layer'], function () {
  344. layui.layer.msg(msg, success);
  345. });
  346. },
  347. addBrokerage:function(){
  348. if (this.brokerage.brokerage >= 0 && this.brokerage.brokerage_two >= 0){
  349. var that = this;
  350. this.$set(this.formData,'attrs',this.formData.attrs.map(function (item) {
  351. item.brokerage = that.brokerage.brokerage;
  352. item.brokerage_two = that.brokerage.brokerage_two;
  353. return item;
  354. }));
  355. } else {
  356. return this.showMsg('请填写返佣金额在进行批量添加');
  357. }
  358. },
  359. batchClear:function(){
  360. this.$set(this,'batchAttr',{
  361. pic: '',
  362. price: 0,
  363. cost: 0,
  364. ot_price: 0,
  365. stock: 0,
  366. bar_code: '',
  367. weight: 0,
  368. volume: 0,
  369. });
  370. },
  371. /**
  372. * 批量添加
  373. * */
  374. batchAdd:function(){
  375. var that = this;
  376. this.$set(this.formData,'attrs',this.formData.attrs.map(function (item) {
  377. if (that.batchAttr.pic) {
  378. item.pic = that.batchAttr.pic;
  379. }
  380. if (that.batchAttr.price > 0){
  381. item.price = that.batchAttr.price;
  382. }
  383. if (that.batchAttr.cost > 0){
  384. item.cost = that.batchAttr.cost;
  385. }
  386. if (that.batchAttr.ot_price > 0){
  387. item.ot_price = that.batchAttr.ot_price;
  388. }
  389. if (that.batchAttr.stock > 0){
  390. item.stock = that.batchAttr.stock;
  391. }
  392. if (that.batchAttr.bar_code != ''){
  393. item.bar_code = that.batchAttr.bar_code;
  394. }
  395. if (that.batchAttr.weight > 0){
  396. item.weight = that.batchAttr.weight;
  397. }
  398. if (that.batchAttr.volume > 0){
  399. item.volume = that.batchAttr.volume;
  400. }
  401. return item;
  402. }));
  403. },
  404. /**
  405. * 获取商品信息
  406. * */
  407. getProductInfo: function () {
  408. var that = this;
  409. that.requestGet(that.U({c:"store.StoreProduct",a:'get_product_info',q:{id:that.id}})).then(function (res) {
  410. that.$set(that,'cateList',res.data.cateList);
  411. that.$set(that,'tempList',res.data.tempList);
  412. var productInfo = res.data.productInfo || {};
  413. if(productInfo.id && that.id){
  414. that.$set(that,'formData',productInfo);
  415. that.generate();
  416. }
  417. that.getRuleList();
  418. that.init();
  419. }).catch(function (res) {
  420. that.showMsg(res.msg);
  421. })
  422. },
  423. /**
  424. * 给某个属性添加属性值
  425. * @param item
  426. * */
  427. addDetail: function (item) {
  428. if (!item.detailValue) return false;
  429. if (item.detail.find(function (val) {
  430. if(item.detailValue == val){
  431. return true;
  432. }
  433. })) {
  434. return this.showMsg('添加的属性值重复');
  435. }
  436. item.detail.push(item.detailValue);
  437. item.detailValue = '';
  438. },
  439. /**
  440. * 删除某个属性值
  441. * @param item 父级循环集合
  442. * @param inx 子集index
  443. * */
  444. deleteValue: function (item, inx) {
  445. if (item.detail.length > 1) {
  446. item.detail.splice(inx, 1);
  447. } else {
  448. return this.showMsg('请设置至少一个属性');
  449. }
  450. },
  451. /**
  452. * 删除某条属性
  453. * @param index
  454. * */
  455. deleteItem: function (index) {
  456. this.formData.items.splice(index, 1);
  457. },
  458. /**
  459. * 删除某条属性
  460. * @param index
  461. * */
  462. deleteAttrs: function (index) {
  463. var that = this;
  464. if(that.id > 0){
  465. that.requestGet(that.U({c:"store.StoreProduct",a:'check_activity',q:{id:that.id}})).then(function (res) {
  466. that.showMsg(res.msg);
  467. }).catch(function (res) {
  468. if (that.formData.attrs.length > 1) {
  469. that.formData.attrs.splice(index, 1);
  470. } else {
  471. return that.showMsg('请设置至少一个规则');
  472. }
  473. })
  474. }else{
  475. if (that.formData.attrs.length > 1) {
  476. that.formData.attrs.splice(index, 1);
  477. } else {
  478. return that.showMsg('请设置至少一个规则');
  479. }
  480. }
  481. },
  482. /**
  483. * 创建属性
  484. * */
  485. createAttrName: function () {
  486. if (this.formDynamic.attrsName && this.formDynamic.attrsVal) {
  487. if (this.formData.items.find(function (val) {
  488. if (val.value == this.formDynamic.attrsName) {
  489. return true;
  490. }
  491. }.bind(this))) {
  492. return this.showMsg('添加的属性重复');
  493. }
  494. this.formData.items.push({
  495. value: this.formDynamic.attrsName,
  496. detailValue: '',
  497. attrHidden: false,
  498. detail: [this.formDynamic.attrsVal]
  499. });
  500. this.formDynamic.attrsName = '';
  501. this.formDynamic.attrsVal = '';
  502. this.newRule = false;
  503. } else {
  504. return this.showMsg('请添加完整的规格!');
  505. }
  506. },
  507. /**
  508. * 删除图片
  509. * */
  510. deleteImage: function (key, index) {
  511. var that = this;
  512. if (index != undefined) {
  513. that.formData[key].splice(index, 1);
  514. that.$set(that.formData, key, that.formData[key]);
  515. } else {
  516. that.$set(that.formData, key, '');
  517. }
  518. },
  519. createFrame: function (title, src, opt) {
  520. opt === undefined && (opt = {});
  521. var h = 0;
  522. if (window.innerHeight < 800 && window.innerHeight >= 700) {
  523. h = window.innerHeight - 50;
  524. } else if (window.innerHeight < 900 && window.innerHeight >= 800) {
  525. h = window.innerHeight - 100;
  526. } else if (window.innerHeight < 1000 && window.innerHeight >= 900) {
  527. h = window.innerHeight - 150;
  528. } else if (window.innerHeight >= 1000) {
  529. h = window.innerHeight - 200;
  530. } else {
  531. h = window.innerHeight;
  532. }
  533. var area = [(opt.w || window.innerWidth / 2) + 'px', (!opt.h || opt.h > h ? h : opt.h) + 'px'];
  534. layui.use('layer',function () {
  535. return layer.open({
  536. type: 2,
  537. title: title,
  538. area: area,
  539. fixed: false, //不固定
  540. maxmin: true,
  541. moveOut: false,//true 可以拖出窗外 false 只能在窗内拖
  542. anim: 5,//出场动画 isOutAnim bool 关闭动画
  543. offset: 'auto',//['100px','100px'],//'auto',//初始位置 ['100px','100px'] t[ 上 左]
  544. shade: 0,//遮罩
  545. resize: true,//是否允许拉伸
  546. content: src,//内容
  547. move: '.layui-layer-title'
  548. });
  549. });
  550. },
  551. changeIMG: function (name, value) {
  552. if (this.getRule(name).maxLength !== undefined) {
  553. var that = this;
  554. value.map(function (v) {
  555. that.formData[name].push(v);
  556. });
  557. this.$set(this.formData, name, this.formData[name]);
  558. } else {
  559. if(name == 'batchAttr.pic'){
  560. this.batchAttr.pic = value;
  561. } else {
  562. if (name.indexOf('.') !== -1) {
  563. var key = name.split('.');
  564. if (key.length == 2){
  565. this.formData[key[0]][key[1]] = value;
  566. } else if(key.length == 3){
  567. this.formData[key[0]][key[1]][key[2]] = value;
  568. } else if(key.length == 4){
  569. this.$set(this.formData[key[0]][key[1]][key[2]],key[3],value)
  570. }
  571. } else {
  572. this.formData[name] = value;
  573. }
  574. }
  575. }
  576. },
  577. getRule: function (name) {
  578. return this.rule[name] || {};
  579. },
  580. uploadImage: function (name) {
  581. return this.createFrame('选择图片',this.U({c:"widget.images",a:'index',p:{fodder:name}}),{h:545,w:900});
  582. },
  583. uploadVideo: function () {
  584. if (this.videoLink) {
  585. this.formData.video_link = this.videoLink;
  586. } else {
  587. $(this.$refs.filElem).click();
  588. }
  589. },
  590. delVideo: function () {
  591. var that = this;
  592. that.$set(that.formData, 'video_link', '');
  593. },
  594. insertEditor: function (list) {
  595. this.um.execCommand('insertimage', list);
  596. },
  597. insertEditorVideo: function (src) {
  598. 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);
  599. },
  600. getContent: function () {
  601. return this.um.getContent();
  602. },
  603. /**
  604. * 监听radio字段
  605. */
  606. eeventRadio: function () {
  607. var that = this;
  608. that.radioRule.map(function (val) {
  609. that.form.on('radio(' + val + ')', function (res) {
  610. that.formData[val] = res.value;
  611. });
  612. })
  613. },
  614. init: function () {
  615. var that = this;
  616. window.UMEDITOR_CONFIG.toolbar = [
  617. // 加入一个 test
  618. 'source | undo redo | bold italic underline strikethrough | superscript subscript | forecolor backcolor | removeformat |',
  619. 'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontfamily fontsize',
  620. '| justifyleft justifycenter justifyright justifyjustify |',
  621. 'link unlink | emotion selectimgs video | map',
  622. '| horizontal print preview fullscreen', 'drafts', 'formula'
  623. ];
  624. UM.registerUI('selectimgs', function (name) {
  625. var me = this;
  626. var $btn = $.eduibutton({
  627. icon: 'image',
  628. click: function () {
  629. that.createFrame('选择图片', "{:Url('widget.images/index',['fodder'=>'editor'])}");
  630. },
  631. title: '选择图片'
  632. });
  633. this.addListener('selectionchange', function () {
  634. //切换为不可编辑时,把自己变灰
  635. var state = this.queryCommandState(name);
  636. $btn.edui().disabled(state == -1).active(state == 1)
  637. });
  638. return $btn;
  639. });
  640. UM.registerUI('video', function (name) {
  641. var me = this;
  642. var $btn = $.eduibutton({
  643. icon: 'video',
  644. click: function () {
  645. that.createFrame('选择视频', "{:Url('widget.video/index',['fodder'=>'video'])}");
  646. },
  647. title: '选择视频'
  648. });
  649. this.addListener('selectionchange', function () {
  650. //切换为不可编辑时,把自己变灰
  651. var state = this.queryCommandState(name);
  652. $btn.edui().disabled(state == -1).active(state == 1)
  653. });
  654. return $btn;
  655. });
  656. //实例化编辑器
  657. this.um = UM.getEditor('myEditor', {initialFrameWidth: '99%', initialFrameHeight: 400});
  658. this.um.setContent(that.formData.description);
  659. that.$nextTick(function () {
  660. layui.use(['form','element'], function () {
  661. that.form = layui.form;
  662. that.form.render();
  663. that.form.on('select(temp_id)', function (data) {
  664. that.$set(that.formData, 'temp_id', data.value);
  665. });
  666. that.form.on('select(rule_index)', function (data) {
  667. that.ruleIndex = data.value;
  668. });
  669. layui.element.on('tab(docTabBrief)', function(){
  670. that.layTabId = this.getAttribute('lay-id');
  671. });
  672. that.eeventRadio();
  673. });
  674. layui.config({
  675. base : '/static/plug/layui/'
  676. }).extend({
  677. selectN: './selectN',
  678. }).use('selectM',function () {
  679. var selectM = layui.selectM;
  680. selectM({
  681. //元素容器【必填】
  682. elem: '#id'
  683. //候选数据【必填】
  684. ,data: that.cateList
  685. //默认值
  686. ,selected: that.formData.id || []
  687. //最多选中个数,默认5
  688. ,max : 10
  689. ,name: 'id'
  690. ,model: 'formData.id'
  691. //值的分隔符
  692. ,delimiter: ','
  693. //候选项数据的键名
  694. ,field: {idName:'value',titleName:'label',statusName:'disabled'}
  695. });
  696. });
  697. })
  698. },
  699. requestPost: function (url, data) {
  700. return new Promise(function (resolve, reject) {
  701. axios.post(url, data).then(function (res) {
  702. if (res.status == 200 && res.data.code == 200) {
  703. resolve(res.data)
  704. } else {
  705. reject(res.data);
  706. }
  707. }).catch(function (err) {
  708. reject({msg:err})
  709. });
  710. })
  711. },
  712. requestGet: function (url) {
  713. return new Promise(function (resolve, reject) {
  714. axios.get(url).then(function (res) {
  715. if (res.status == 200 && res.data.code == 200) {
  716. resolve(res.data)
  717. } else {
  718. reject(res.data);
  719. }
  720. }).catch(function (err) {
  721. reject({msg:err})
  722. });
  723. })
  724. },
  725. generates: function () {
  726. var that = this;
  727. that.generate(1);
  728. },
  729. generate: function (type = 0) {
  730. var that = this;
  731. this.requestPost(that.U({c:"store.StoreProduct",a:'is_format_attr',p:{id:that.id,type:type}}), {attrs:this.formData.items}).then(function (res) {
  732. that.$set(that.formData, 'attrs', res.data.value);
  733. that.$set(that, 'formHeader', res.data.header);
  734. if (that.id && that.formData.is_sub == 1 && that.formData.spec_type == 1) {
  735. that.formHeader.push({title:'一级返佣(元)'});
  736. that.formHeader.push({title:'二级级返佣(元)'});
  737. }
  738. }).catch(function (res) {
  739. return that.showMsg(res.msg);
  740. });
  741. },
  742. handleSubmit:function () {
  743. var that = this;
  744. var time = $('#time').val();
  745. var rtime = $('#rtime').val();
  746. that.formData.time = time;
  747. that.formData.rtime = rtime;
  748. if (!that.formData['nickname']){
  749. return that.showMsg('请填写名称');
  750. }
  751. if (!that.formData['image']){
  752. return that.showMsg('请上传图片');
  753. }
  754. if (!that.formData['time']){
  755. return that.showMsg('请选择预约时间');
  756. }
  757. if (!that.formData['rtime']){
  758. return that.showMsg('请选择进场时间');
  759. }
  760. $('#submit').attr('disabled', 'disabled').text('保存中...');
  761. that.requestPost(that.U({c:'auction.auction',a:'save',p:{id:that.id}}),that.formData).then(function (res) {
  762. that.confirm();
  763. }).catch(function (res) {
  764. that.showMsg(res.msg);
  765. });
  766. },
  767. confirm: function(){
  768. var that = this;
  769. layui.use(['layer'], function () {
  770. var layer = layui.layer;
  771. layer.confirm(that.id ? '修改成功是否返回产品列表' : '添加成功是否返回产品列表', {
  772. btn: ['返回列表',that.id ? '继续修改' : '继续添加'] //按钮
  773. }, function(){
  774. location.href = that.U({c:'auction.auction',a:'index'});
  775. }, function(){
  776. location.reload();
  777. });
  778. });
  779. },
  780. render:function(){
  781. this.$nextTick(function(){
  782. layui.use(['form'], function () {
  783. layui.form.render('select');
  784. });
  785. })
  786. },
  787. // 移动
  788. handleDragStart (e, item) {
  789. this.dragging = item;
  790. },
  791. handleDragEnd (e, item) {
  792. this.dragging = null
  793. },
  794. handleDragOver (e) {
  795. e.dataTransfer.dropEffect = 'move'
  796. },
  797. handleDragEnter (e, item) {
  798. e.dataTransfer.effectAllowed = 'move'
  799. if (item === this.dragging) {
  800. return
  801. }
  802. var newItems = [...this.formData.activity];
  803. var src = newItems.indexOf(this.dragging);
  804. var dst = newItems.indexOf(item);
  805. newItems.splice(dst, 0, ...newItems.splice(src, 1))
  806. this.formData.activity = newItems;
  807. },
  808. getRuleList:function (type) {
  809. var that = this;
  810. that.requestGet(that.U({c:'store.StoreProduct',a:'get_rule'})).then(function (res) {
  811. that.$set(that,'ruleList',res.data);
  812. if(type !== undefined){
  813. that.render();
  814. }
  815. });
  816. },
  817. addRule:function(){
  818. return this.createFrame('添加商品规则',this.U({c:'store.StoreProductRule',a:'create'}));
  819. },
  820. allRule:function () {
  821. if (this.ruleIndex != -1) {
  822. var rule = this.ruleList[this.ruleIndex];
  823. if (rule) {
  824. this.ruleBool = true;
  825. var rule_value = rule.rule_value.map(function (item) {
  826. return item;
  827. });
  828. this.$set(this.formData,'items',rule_value);
  829. this.$set(this.formData,'attrs',[]);
  830. this.$set(this,'formHeader',[]);
  831. return true;
  832. }
  833. }
  834. this.showMsg('选择的属性无效');
  835. }
  836. },
  837. mounted: function () {
  838. var that = this;
  839. axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  840. that.getProductInfo();
  841. window.$vm = that;
  842. window.changeIMG = that.changeIMG;
  843. window.insertEditor = that.insertEditor;
  844. window.insertEditorVideo = that.insertEditorVideo;
  845. window.successFun = function(){
  846. that.getRuleList(1);
  847. }
  848. $(that.$refs.filElem).change(function () {
  849. var inputFile = this.files[0];
  850. that.requestPost(that.U({c:"widget.video",a:'get_signature'})).then(function (res) {
  851. AdminUpload.upload(res.data.uploadType,{
  852. token: res.data.uploadToken || '',
  853. file: inputFile,
  854. accessKeyId: res.data.accessKey || '',
  855. accessKeySecret: res.data.secretKey || '',
  856. bucketName: res.data.storageName || '',
  857. region: res.data.storageRegion || '',
  858. domain: res.data.domain || '',
  859. uploadIng:function (progress) {
  860. that.upload.videoIng = true;
  861. that.progress = progress;
  862. }
  863. }).then(function (res) {
  864. //成功
  865. that.$set(that.formData, 'video_link', res.url);
  866. that.progress = 0;
  867. that.upload.videoIng = false;
  868. return that.showMsg('上传成功');
  869. }).catch(function (err) {
  870. //失败
  871. console.info(err);
  872. return that.showMsg('上传错误请检查您的配置');
  873. });
  874. }).catch(function (res) {
  875. return that.showMsg(res.msg || '获取密钥失败,请检查您的配置');
  876. });
  877. })
  878. }
  879. });
  880. </script>
  881. </body>
  882. </html>
  883. <script>
  884. import Layout from "../../../../../public/static/plug/iview/dist/iview";
  885. export default {
  886. components: {Layout}
  887. }
  888. </script>