create.php 41 KB

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