index.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. {extend name="public/container"}
  2. {block name='head_top'}
  3. <style>
  4. #app .layui-form-label{padding: 9px 15px;width: 80px;}
  5. #app .layui-input-margin-5{margin-top: 5px}
  6. #app .layui-input-image{width: 100px;height: 100px;}
  7. #app .layui-box{width:100px;height:140px;display: inline-block;margin-right: 10px;margin-bottom: 10px;padding: 2px;border: 1px dashed #0d8ddb;border-radius: 3px;text-align: center;}
  8. #app .layui-box img{width: 100px;height: 100px;margin: 0 auto;display: block;}
  9. #app .layui-box.box-border-color{border: 1px solid #0bb20c;}
  10. #app .layui-box .layui-text{background: rgba(0,0,0,.3);}
  11. #app .layui-box .layui-text p{width: 50%;display: inline;text-align: center;}
  12. #app .spinner {margin: 50px auto;width: 50px;height: 60px;text-align: center;font-size: 10px;}
  13. #app .spinner > div {background-color: #0092DC;height: 100%;width: 6px;display: inline-block;-webkit-animation: stretchdelay 1.2s infinite ease-in-out;animation: stretchdelay 1.2s infinite ease-in-out;}
  14. #app .spinner .rect2 {-webkit-animation-delay: -1.1s;animation-delay: -1.1s;}
  15. #app .spinner .rect3 {-webkit-animation-delay: -1.0s;animation-delay: -1.0s;}
  16. #app .spinner .rect4 {-webkit-animation-delay: -0.9s;animation-delay: -0.9s;}
  17. #app .spinner .rect5 {-webkit-animation-delay: -0.8s;animation-delay: -0.8s;}
  18. #app .save-button{position: fixed;width: 100%;bottom: 0;}
  19. .red {color: red;}
  20. @-webkit-keyframes stretchdelay { 0%, 40%, 100% { -webkit-transform: scaleY(0.4) } 20% { -webkit-transform: scaleY(1.0) } }
  21. @keyframes stretchdelay { 0%, 40%, 100% {transform: scaleY(0.4);-webkit-transform: scaleY(0.4);} 20% {transform: scaleY(1.0);-webkit-transform: scaleY(1.0);} }
  22. </style>
  23. {/block}
  24. {block name="content"}
  25. <div class="layui-fluid">
  26. <div class="layui-row layui-col-space15" id="app" v-cloak="">
  27. <div class="layui-col-md12">
  28. <div class="layui-card">
  29. <div class="layui-card-body">
  30. <blockquote class="layui-elem-quote layui-quote-nm">
  31. <p style="color: red">注意:当前采集方式为免费采集,受到淘宝店铺影响需要登陆才可以访问产品详情,可能会导致采集程序不稳定,都属于正常现象,尽情谅解,后期会开发出付费接口采集保证稳定采集!</p>
  32. 链接格式说明: 输入以http或https开头的淘宝、天猫、1688、京东的商品详情页网址,网址正确且商品信息存在时才能入库成功。生成的产品默认是没有上架的,请手动上架产品!轮播图选中的颜色是绿色边框的请注意
  33. </blockquote>
  34. <div class="layui-form-item">
  35. <label class="layui-form-label">链接地址</label>
  36. <div class="layui-input-block">
  37. <input type="text" style="width: 80%;display: inline-block;vertical-align: middle" v-model="link" autocomplete="off" placeholder="链接地址" class="layui-input">
  38. <button @click="checkUrl" class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search" lay-filter="search" style="vertical-align: middle">
  39. <i class="layui-icon layui-icon-add-1"></i>确定</button>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="layui-card" v-if="isLink && link">
  45. <div class="layui-card-header">商品编辑</div>
  46. <div class="layui-card-body">
  47. <form class="layui-form" action="">
  48. <div class="layui-form-item">
  49. <label class="layui-form-label">选择分类<i class="red">*</i></label>
  50. <div class="layui-input-block">
  51. <select name="cate_id" v-model="productInfo.cate_id" lay-verify="cate_id" lay-filter="cate_id">
  52. <option value="">请选择</option>
  53. <option :value="item.value" v-for="item in categoryList" :key="item.id" :disabled="item.disabled" v-text="item.label"></option>
  54. </select>
  55. </div>
  56. </div>
  57. <div class="layui-form-item">
  58. <label class="layui-form-label">产品名称<i class="red">*</i></label>
  59. <div class="layui-input-block">
  60. <input type="text" name="title" v-model="productInfo.store_name" autocomplete="off" placeholder="请输入产品名称" class="layui-input">
  61. </div>
  62. </div>
  63. <div class="layui-form-item layui-form-text">
  64. <label class="layui-form-label">产品简介</label>
  65. <div class="layui-input-block">
  66. <textarea placeholder="请输入内容" class="layui-textarea" v-model="productInfo.store_info"></textarea>
  67. </div>
  68. </div>
  69. <div class="layui-form-item layui-input-margin-5">
  70. <div class="layui-inline">
  71. <label class="layui-form-label">产品关键字</label>
  72. <div class="layui-input-inline">
  73. <input type="text" name="text" autocomplete="off" class="layui-input" v-model="productInfo.keyword">
  74. </div>
  75. </div>
  76. <div class="layui-inline">
  77. <label class="layui-form-label">产品单位</label>
  78. <div class="layui-input-inline">
  79. <input type="text" name="text" autocomplete="off" class="layui-input" v-model="productInfo.unit_name">
  80. </div>
  81. </div>
  82. <div class="layui-inline">
  83. <label class="layui-form-label">产品售价<i class="red">*</i></label>
  84. <div class="layui-input-inline">
  85. <input type="number" name="number" autocomplete="off" class="layui-input" v-model="productInfo.price">
  86. </div>
  87. </div>
  88. </div>
  89. <div class="layui-form-item layui-input-margin-5">
  90. <div class="layui-inline">
  91. <label class="layui-form-label">产品市场价<i class="red">*</i></label>
  92. <div class="layui-input-inline">
  93. <input type="number" name="number" autocomplete="off" class="layui-input" v-model="productInfo.ot_price">
  94. </div>
  95. </div>
  96. <div class="layui-inline">
  97. <label class="layui-form-label">赠送积分</label>
  98. <div class="layui-input-inline">
  99. <input type="number" name="number" autocomplete="off" class="layui-input" v-model="productInfo.give_integral">
  100. </div>
  101. </div>
  102. <div class="layui-inline">
  103. <label class="layui-form-label">运费模板<i class="red">*</i></label>
  104. <div class="layui-input-inline">
  105. <select name="cate_id" v-model="productInfo.temp_id" lay-filter="temp_id">
  106. <option value="">请选择</option>
  107. <option :value="item.id" v-for="item in templatesList" :key="item.id" v-text="item.name"></option>
  108. </select>
  109. </div>
  110. </div>
  111. </div>
  112. <div class="layui-form-item layui-input-margin-5">
  113. <div class="layui-inline">
  114. <label class="layui-form-label">虚拟销量</label>
  115. <div class="layui-input-inline">
  116. <input type="number" name="number" autocomplete="off" class="layui-input" v-model="productInfo.ficti">
  117. </div>
  118. </div>
  119. <div class="layui-inline">
  120. <label class="layui-form-label">库存<i class="red">*</i></label>
  121. <div class="layui-input-inline">
  122. <input type="number" name="number" autocomplete="off" class="layui-input" v-model="productInfo.stock">
  123. </div>
  124. </div>
  125. <div class="layui-inline">
  126. <label class="layui-form-label">产品成本价<i class="red">*</i></label>
  127. <div class="layui-input-inline">
  128. <input type="number" name="number" autocomplete="off" class="layui-input" v-model="productInfo.cost">
  129. </div>
  130. </div>
  131. </div>
  132. <div class="layui-form-item">
  133. <label class="layui-form-label">产品主图片(305*305px)<i class="red">*</i></label>
  134. <div class="layui-input-block">
  135. <div class="layui-box box-border-color" style="height: 100px;">
  136. <img :src="productInfo.image" alt="" class="layui-input-image" @click="lookImage(productInfo.image)">
  137. </div>
  138. </div>
  139. </div>
  140. <div class="layui-form-item">
  141. <label class="layui-form-label">产品轮播图(640*640px)<i class="red">*</i></label>
  142. <div class="layui-input-block">
  143. <div class="layui-box" :class="item.isSelect ? 'box-border-color':'' " v-for="(item,index) in productInfo.slider_image" >
  144. <img :src="item.pic" alt="" class="layui-input-image" @click="lookImage(item.pic)">
  145. <div class="layui-btn-group" style="margin-top: 12px">
  146. <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" @click=" productInfo.image=item.pic ">主图</button>
  147. <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" @click="item.isSelect = !item.isSelect">{{ item.isSelect ? '移除': '选中' }}</button>
  148. </div>
  149. </div>
  150. </div>
  151. </div>
  152. <!-- <div class="layui-form-item" v-if="productInfo.description_images.length">-->
  153. <!-- <label class="layui-form-label">详情图片</label>-->
  154. <!-- <div class="layui-input-block">-->
  155. <!-- <div class="layui-box" :class="item.isSelect ? 'box-border-color':'' " v-for="(item,index) in productInfo.description_images" >-->
  156. <!-- <img :src="item.pic" alt="" class="layui-input-image" @click="lookImage(item.pic)">-->
  157. <!-- <div class="layui-btn-group" style="margin-top: 12px">-->
  158. <!-- <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" @click="item.isSelect = !item.isSelect">{{ item.isSelect ? '移除': '选中' }}</button>-->
  159. <!-- </div>-->
  160. <!-- </div>-->
  161. <!-- </div>-->
  162. <!-- </div>-->
  163. <div class="layui-form-item layui-input-margin-5" style="margin-bottom: 40px;">
  164. <label class="layui-form-label">详情内容</label>
  165. <div class="layui-input-block">
  166. <textarea id="description" style="display: none;" class="layui-textarea" v-model="productInfo.description"></textarea>
  167. </div>
  168. </div>
  169. </form>
  170. </div>
  171. <button class="layui-btn save-button" type="button" @click="saveProduct">立即保存</button>
  172. </div>
  173. <div class="layui-card" v-if="isLink==false && link && loading">
  174. <div class="spinner">
  175. <div class="rect1"></div>
  176. <div class="rect2"></div>
  177. <div class="rect3"></div>
  178. <div class="rect4"></div>
  179. <div class="rect5"></div>
  180. </div>
  181. </div>
  182. </div>
  183. </div>
  184. </div>
  185. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  186. {/block}
  187. {block name="script"}
  188. <script>
  189. layList.form.render();
  190. require(['vue'],function(Vue) {
  191. new Vue({
  192. el: "#app",
  193. data: {
  194. categoryList:<?=json_encode($menus)?>,
  195. link:'',
  196. linkhistory:'',
  197. isLink:false,
  198. loading:false,
  199. productInfo:{
  200. description_images:[],
  201. },
  202. slider_image:[],
  203. editIndex:0,
  204. templatesList:[],
  205. },
  206. methods:{
  207. checkUrl:function () {
  208. if(!this.link) return layList.msg('请输入链接地址');
  209. if(this.link==this.linkhistory) return false;
  210. this.linkhistory=this.link;
  211. this.loading=true;
  212. layList.basePost(layList.U({a:'get_request_contents'}),{link:this.link},function (res) {
  213. this.loading=false;
  214. this.linkhistory='';
  215. var slider_image=res.data.slider_image,slider_image_new=[],description_images=res.data.description_images,description_images_new=[];
  216. for (var i=0;i<slider_image.length;i++){
  217. slider_image_new.push({pic:slider_image[i],isSelect:true});
  218. }
  219. for(var k=0;k<description_images.length;k++){
  220. description_images_new.push({pic:description_images[k],isSelect:true});
  221. }
  222. res.data.slider_image=slider_image_new;
  223. res.data.description_images=description_images_new;
  224. this.productInfo=res.data;
  225. this.isLink=true;
  226. this.$set(this,'productInfo',this.productInfo);
  227. this.$nextTick(function () {
  228. this.editIndex = layList.layedit.build('description',{
  229. tool: ['strong', 'italic', 'underline', 'del','|', 'left','center','right','link','unlink','face']
  230. });
  231. this.getFreightTemplateList();
  232. }.bind(this));
  233. }.bind(this),function (res) {
  234. this.loading=false;
  235. this.linkhistory='';
  236. layList.msg(res.msg);
  237. }.bind(this));
  238. },
  239. lookImage:function (pic) {
  240. if($eb) $eb.openImage(pic);
  241. },
  242. saveProduct:function () {
  243. var that=this,productInfo={
  244. cate_id:that.productInfo.cate_id,
  245. store_name:that.productInfo.store_name,
  246. store_info:that.productInfo.store_info,
  247. ficti:that.productInfo.ficti,
  248. unit_name:that.productInfo.unit_name,
  249. slider_image:that.productInfo.slider_image,
  250. price:that.productInfo.price,
  251. image:that.productInfo.image,
  252. keyword:that.productInfo.keyword,
  253. give_integral:that.productInfo.give_integral,
  254. give_integral:that.productInfo.give_integral,
  255. ot_price:that.productInfo.ot_price,
  256. stock:that.productInfo.stock,
  257. cost:that.productInfo.cost,
  258. postage:that.productInfo.postage,
  259. description:that.productInfo.description,
  260. temp_id:that.productInfo.temp_id,
  261. description_images:that.productInfo.description_images,
  262. soure_link:that.link,
  263. };
  264. if(!that.productInfo.cate_id) return layList.msg('请选择分类');
  265. if(!that.productInfo.store_name) return layList.msg('请填写商品名称');
  266. if(!that.productInfo.unit_name) return layList.msg('请填写产品单位');
  267. if(!that.productInfo.price) return layList.msg('请填写产品价格');
  268. if(!that.productInfo.ot_price) return layList.msg('请填写产品市场价');
  269. if(!that.productInfo.cost) return layList.msg('请填写产品成本价');
  270. if(!that.productInfo.stock) return layList.msg('请填写产品库存');
  271. if(!that.productInfo.temp_id) return layList.msg('请选择运费模板');
  272. productInfo.slider_image=that.setArraySelect(productInfo.slider_image);
  273. productInfo.description_images=that.setArraySelect(productInfo.description_images);
  274. productInfo.description=layList.layedit.getContent(that.editIndex);
  275. layList.layer.confirm('保存产品生成图片可能较慢,保存中请耐心等待,请不要关闭窗口!确认生成产品和图片吗?', {
  276. btn: ['确定生成','我在想想'] //按钮
  277. }, function(){
  278. var index = layList.layer.load(1, {shade: [0.5,'#000000']});
  279. layList.basePost(layList.U({a:'save_product'}),productInfo,function (res) {
  280. layList.layer.close(index);
  281. layList.msg(res.msg,function () {
  282. var res=layList.layer.confirm('是否要继续添加?', {
  283. btn: ['是的','不了我要关闭'] //按钮
  284. },function () {
  285. that.productInfo={description_images:[]};
  286. that.link='';
  287. that.linkhistory='';
  288. that.$set(that,'productInfo',that.productInfo);
  289. layList.layer.close(res);
  290. },function () {
  291. parent.layer.close(parent.layer.getFrameIndex(window.name));
  292. })
  293. })
  294. },function (res){
  295. layList.layer.close(index);
  296. layList.msg(res.msg);
  297. });
  298. });
  299. },
  300. setArraySelect:function (Arraylist) {
  301. var list=[];
  302. for(var i=0,len=Arraylist.length;i<len;i++) {
  303. if(Arraylist[i].isSelect) list.push(Arraylist[i].pic);
  304. }
  305. return list;
  306. },
  307. getFreightTemplateList:function () {
  308. var that = this;
  309. layList.baseGet(layList.U({c:"setting.shipping_templates",a:'get_template_list'}),function (res) {
  310. that.$set(that,'templatesList',res.data);
  311. that.$nextTick(function () {
  312. layList.form.render('select');
  313. layList.select('temp_id',function (data) {
  314. that.productInfo.temp_id = data.value;
  315. });
  316. })
  317. });
  318. }
  319. },
  320. mounted:function () {
  321. var that=this;
  322. this.$nextTick(function () {
  323. layList.form.render();
  324. layList.select('cate_id',function (data) {
  325. that.productInfo.cate_id=data.value;
  326. });
  327. })
  328. }
  329. })
  330. })
  331. </script>
  332. {/block}