create.php 44 KB

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