d7d372ab726862fb447d17cfe02c83d6.php 43 KB

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