fz.php 44 KB

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