index.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. <div id="app" v-cloak>
  2. <el-card shadow="never" style="border:0;min-width: 1200px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  3. <div slot="header">
  4. <div style="display: flex; justify-content:space-between">
  5. <span>基础设置</span>
  6. <div>
  7. <el-button size="small" type="primary" style="padding: 9px 15px !important;" @click="onSubmit">保存配置</el-button>
  8. </div>
  9. </div>
  10. </div>
  11. <div class="table-body">
  12. <el-tabs v-model="activeName" @tab-click="handleClick">
  13. <el-form size="small" ref="form" label-width="180px" :model="form" :rules="rules">
  14. <el-form-item label="是否启用插件" prop="is_enable">
  15. <el-switch
  16. v-model="form.is_enable"
  17. :active-value="1"
  18. :inactive-value="0">
  19. </el-switch>
  20. </el-form-item>
  21. <el-form-item label="自动更新商品售价" prop="auto_update_price">
  22. <el-switch
  23. v-model="form.auto_update_price"
  24. :active-value="1"
  25. :inactive-value="0">
  26. </el-switch>
  27. </el-form-item>
  28. <el-form-item v-if="admin_type == 1" label="标准选品库" prop="is_default">
  29. <el-switch
  30. v-model="form.is_default"
  31. :active-value="1"
  32. :inactive-value="0">
  33. </el-switch>
  34. </el-form-item>
  35. <div v-if="form.is_default">
  36. <el-form-item prop="app_key" label="AppKey" prop="app_key" :rules="[{required:true, message: 'AppKey不能为空'}]">
  37. <el-col :span="24">
  38. <el-input style="width: 500px" v-model="form.app_key">
  39. </el-input>
  40. </el-col>
  41. </el-form-item>
  42. <el-form-item prop="token" label="Token" prop="token" :rules="[{required:true, message: 'Token不能为空'}]">
  43. <el-col :span="24">
  44. <el-input style="width: 500px" v-model="form.token"></el-input>
  45. </el-col>
  46. </el-form-item>
  47. <el-form-item label="Public Key" prop="public_key" :rules="[{required:true, message: '公钥不能为空'}]">
  48. <el-input style="width: 500px" v-model="form.public_key" :placeholder="form.public_key" :disabled="true">
  49. <template #append>
  50. <input ref="public_key" type="file" accept=".key" :multiple="false" style="display: none"
  51. @change="handleChange">
  52. <el-button size="small" @click="uploadPem('public_key')">上传Public Key</el-button>
  53. </template>
  54. </el-input>
  55. </el-form-item>
  56. <el-form-item label="订单通知地址">
  57. <el-col :span="24">
  58. <el-input style="width: 500px" v-model="order_callback_url" disabled>
  59. <template #append><el-button @click="copyLink(order_callback_url)" class="copy_btn">点击复制</el-button></template>
  60. </el-input>
  61. </el-col>
  62. </el-form-item>
  63. <el-form-item label="商品修改通知地址">
  64. <el-col :span="24">
  65. <el-input style="width: 500px" v-model="goods_callback_url" disabled>
  66. <template #append><el-button @click="copyLink(goods_callback_url)" class="copy_btn">点击复制</el-button></template>
  67. </el-input>
  68. </el-col>
  69. </el-form-item>
  70. </div>
  71. <h3 style="padding-left: 107px">定价策略</h3>
  72. <el-form-item label="售价 定价策略" prop="status">
  73. <el-radio-group v-model="form.price.price.type" size="medium" class="redio-center">
  74. <!-- 指导价 -->
  75. <el-radio label="price">{{''}}</el-radio>
  76. <span class="redio-input">
  77. <el-input minlength="1" maxlength="3" oninput="value=value.replace(/[^\d]/g,'')" style="width:300px;" v-model="form.price.price.rate.price">
  78. <template slot="prepend">供货价 x 定价系数</template>
  79. <template slot="append">%</template>
  80. </el-input>
  81. </span>
  82. <!-- 协议价 -->
  83. <el-radio label="retail_price">{{''}}</el-radio>
  84. <span class="redio-input">
  85. <el-input minlength="1" maxlength="3" oninput="value=value.replace(/[^\d]/g,'')" style="width:300px;" v-model="form.price.price.rate.retail_price">
  86. <template slot="prepend">建议零售价 x 定价系数</template>
  87. <template slot="append">%</template>
  88. </el-input>
  89. </span>
  90. <el-radio label="lowest_price">{{''}}</el-radio>
  91. <span class="redio-input">
  92. <el-input minlength="1" maxlength="3" oninput="value=value.replace(/[^\d]/g,'')" style="width:300px;" v-model="form.price.price.rate.lowest_price">
  93. <template slot="prepend">最低售价 x 定价系数</template>
  94. <template slot="append">%</template>
  95. </el-input>
  96. </span>
  97. </el-radio-group>
  98. <div class="tab_tpis">
  99. 举例:供货价50元 建议零售价100元<br>
  100. 供货价 x 定价系数 即 50 x 130% = 65 元<br>
  101. 建议零售价 x 定价系数 即 100 x 80% = 80 元<br>
  102. 默认为供货价 x 150%(建议零售价不变,供货价上涨可能导致亏损!)<br>
  103. </div>
  104. </el-form-item>
  105. <!-- 成本价 定价策略 -->
  106. <el-form-item label="成本价 定价策略" prop="status">
  107. <el-radio-group v-model="form.price.cost_price.type" size="medium" class="redio-center">
  108. <!-- 指导价 -->
  109. <el-radio label="price">{{''}}</el-radio>
  110. <span class="redio-input">
  111. <el-input minlength="1" maxlength="3" oninput="value=value.replace(/[^\d]/g,'')" style="width:300px;" v-model="form.price.cost_price.rate.price">
  112. <template slot="prepend">供货价 x 定价系数</template>
  113. <template slot="append">%</template>
  114. </el-input>
  115. </span>
  116. <!-- 协议价 -->
  117. <el-radio label="retail_price">{{''}}</el-radio>
  118. <span class="redio-input">
  119. <el-input minlength="1" maxlength="3" oninput="value=value.replace(/[^\d]/g,'')" style="width:300px;" v-model="form.price.cost_price.rate.retail_price">
  120. <template slot="prepend">建议零售价 x 定价系数</template>
  121. <template slot="append">%</template>
  122. </el-input>
  123. </span>
  124. <el-radio label="lowest_price">{{''}}</el-radio>
  125. <span class="redio-input">
  126. <el-input minlength="1" maxlength="3" oninput="value=value.replace(/[^\d]/g,'')" style="width:300px;" v-model="form.price.cost_price.rate.lowest_price">
  127. <template slot="prepend">最低售价 x 定价系数</template>
  128. <template slot="append">%</template>
  129. </el-input>
  130. </span>
  131. </el-radio-group>
  132. </el-form-item>
  133. <!-- 原价 定价策略 -->
  134. <el-form-item label="原价 定价策略" prop="status">
  135. <el-radio-group v-model="form.price.original_price.type" size="medium" class="redio-center">
  136. <!-- 指导价 -->
  137. <el-radio label="price">{{''}}</el-radio>
  138. <span class="redio-input">
  139. <el-input minlength="1" maxlength="3" oninput="value=value.replace(/[^\d]/g,'')" style="width:300px;" v-model="form.price.original_price.rate.price">
  140. <template slot="prepend">供货价 x 定价系数</template>
  141. <template slot="append">%</template>
  142. </el-input>
  143. </span>
  144. <!-- 协议价 -->
  145. <el-radio label="retail_price">{{''}}</el-radio>
  146. <span class="redio-input">
  147. <el-input minlength="1" maxlength="3" oninput="value=value.replace(/[^\d]/g,'')" style="width:300px;" v-model="form.price.original_price.rate.retail_price">
  148. <template slot="prepend">建议零售价 x 定价系数</template>
  149. <template slot="append">%</template>
  150. </el-input>
  151. </span>
  152. <el-radio label="lowest_price">{{''}}</el-radio>
  153. <span class="redio-input">
  154. <el-input minlength="1" maxlength="3" oninput="value=value.replace(/[^\d]/g,'')" style="width:300px;" v-model="form.price.original_price.rate.lowest_price">
  155. <template slot="prepend">最低售价 x 定价系数</template>
  156. <template slot="append">%</template>
  157. </el-input>
  158. </span>
  159. </el-radio-group>
  160. </el-form-item>
  161. <div v-if="form.is_default">
  162. <h3 style="padding-left: 107px">收款设置</h3>
  163. <el-form-item label="联系二维码" prop="contact_image" >
  164. <com-attachment v-model="form.contact_image" :multiple="false" :max="1">
  165. <el-tooltip class="item" effect="dark" content="建议尺寸:500 * 500" placement="top">
  166. <el-button size="mini">选择图片</el-button>
  167. </el-tooltip>
  168. </com-attachment>
  169. <div v-if="form.contact_image" class="customize-share-title" style="width: 80px; height: 80px; overflow: hidden">
  170. <el-image mode="aspectFill" width='80px' height='80px' :src="form.contact_image ? form.contact_image : ''"></el-image>
  171. <el-button v-if="form.contact_image" class="del-btn" size="mini" type="danger" icon="el-icon-close" circle @click="form.contact_image = ''"></el-button>
  172. </div>
  173. </el-form-item>
  174. <el-form-item label="联系电话">
  175. <el-input style="width: 200px" v-model="form.mobile" placeholder="请输入联系电话"></el-input>
  176. </el-form-item>
  177. <el-form-item label="资金低于" prop="min_balance" :rules="[{required: true, message:'请输入资金提醒门槛'}]">
  178. <el-input style="width: 400px" v-model="form.min_balance" placeholder="请输入资金提醒门槛">
  179. <template #append>元,红色数值提醒</template>
  180. </el-input>
  181. </el-form-item>
  182. </div>
  183. </el-form>
  184. </el-tabs>
  185. </div>
  186. <!-- 这个是复制用的容器,已隐藏 -->
  187. <textarea id="inputs" style="opacity: 0;width: 0;height: 0;">这是幕后黑手</textarea>
  188. </el-card>
  189. </div>
  190. <script>
  191. const validateNumber = (rule, value, callback) => {
  192. if (!(/^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/).test(value)) {
  193. callback(new Error('请输入数字值'))
  194. } else {
  195. callback()
  196. }
  197. };
  198. const app = new Vue({
  199. el: '#app',
  200. data: {
  201. activeName: '',
  202. form: {
  203. is_enable: 0,
  204. app_key: '',
  205. token: '',
  206. public_key: '',
  207. is_default: 0,
  208. auto_update_price: 0,
  209. contact_image: '',
  210. mobile: '',
  211. min_balance: 0,
  212. price: {
  213. price: {
  214. type: 'price',
  215. rate: {
  216. price: 150,
  217. retail_price: 150,
  218. lowest_price: 150
  219. },
  220. },
  221. cost_price: {
  222. type: 'price',
  223. rate: {
  224. price: 150,
  225. retail_price: 150,
  226. lowest_price: 150
  227. },
  228. },
  229. original_price: {
  230. type: 'price',
  231. rate: {
  232. price: 150,
  233. retail_price: 150,
  234. lowest_price: 150
  235. },
  236. }
  237. }
  238. },
  239. pem_value: '',
  240. rules: {},
  241. order_callback_url: '<?= $order_callback_url ?>',
  242. goods_callback_url: '<?= $goods_callback_url ?>',
  243. admin_type: '<?= $admin_type ?>',
  244. },
  245. mounted() {
  246. // 获取列表首页数据
  247. this.getData()
  248. },
  249. methods: {
  250. //1.0 跳转详情
  251. handleClick(tab, event) {
  252. },
  253. handleSelectionChange(val) {
  254. let self = this;
  255. self.choose_list = [];
  256. val.forEach(function (item) {
  257. self.choose_list.push(item.id);
  258. })
  259. },
  260. getData() {
  261. this.loading = true
  262. request({
  263. method: 'get',
  264. params: {
  265. r: 'qi-ding-dong/setting/index',
  266. },
  267. }).then(e => {
  268. this.loading = false;
  269. if (e.data.code === 0) {
  270. if (!e.data.data.price) e.data.data.price = this.form.price
  271. this.form = Object.assign(this.form, e.data.data)
  272. } else {
  273. this.$message.error(e.data.msg);
  274. }
  275. }).catch(e => {
  276. this.loading = false;
  277. });
  278. },
  279. onSubmit() {
  280. this.$refs['form'].validate((valid) => {
  281. if (valid) {
  282. this.loading = true
  283. request({
  284. method: 'post',
  285. params: {
  286. r: 'qi-ding-dong/setting/index',
  287. },
  288. data: this.form
  289. }).then(e => {
  290. this.loading = false;
  291. if (e.data.code === 0) {
  292. this.$message.success(e.data.msg);
  293. } else {
  294. this.$message.error(e.data.msg);
  295. }
  296. }).catch(e => {
  297. this.loading = false;
  298. });
  299. } else {
  300. console.log(valid)
  301. }
  302. })
  303. },
  304. uploadPem(key) {
  305. this.pem_value = key;
  306. this.$refs[key].value = null;
  307. this.$refs[key].click();
  308. },
  309. handleChange(e){
  310. const rawFiles = e.target.files;
  311. if (rawFiles.length > 1) {
  312. this.$message.error('最多一次只能上传一个文件。')
  313. return;
  314. }
  315. let file = {
  316. _complete: false,
  317. response: null,
  318. rawFile: rawFiles[0],
  319. };
  320. let formData = new FormData();
  321. const params = {};
  322. params['r'] = 'mall/file/upload';
  323. for (let i in this.params) {
  324. params[i] = this.params[i];
  325. }
  326. for (let i in this.fields) {
  327. formData.append(i, this.fields[i]);
  328. }
  329. formData.append('file', file.rawFile, file.rawFile.name);
  330. this.$request({
  331. headers: {'Content-Type': 'multipart/form-data'},
  332. params: params,
  333. method: 'post',
  334. data: formData,
  335. }).then(e => {
  336. if (e.data.code === 0) {
  337. this.form[this.pem_value] = e.data.data.path;
  338. this.$message.success('上传成功');
  339. } else {
  340. this.$message.error(e.data.msg);
  341. }
  342. }).catch(e => {
  343. this.$message.error('上传失败');
  344. });
  345. },
  346. copyLink(url) { //复制链接
  347. var clipboard = new ClipboardJS('.copy_btn', {
  348. text: function() {
  349. return url;
  350. }
  351. });
  352. clipboard.on('success', (e) => {
  353. this.$message.success('复制成功!');
  354. clipboard.destroy()
  355. });
  356. clipboard.on('error', (e) => {
  357. this.$message.error('复制失败!');
  358. this.clipboard.destroy()
  359. });
  360. },
  361. }
  362. });
  363. </script>
  364. <style>
  365. .el-tabs__header {
  366. font-size: 16px;
  367. }
  368. .table-body {
  369. padding: 20px;
  370. background-color: #fff;
  371. }
  372. .table-body .el-button {
  373. padding: 0 !important;
  374. border: 0;
  375. margin: 0 5px;
  376. }
  377. .input-item {
  378. width: 250px;
  379. margin: 0 0 20px;
  380. display: inline-block;
  381. }
  382. .input-item .el-input__inner {
  383. border-right: 0;
  384. }
  385. .input-item .el-input__inner:hover {
  386. border: 1px solid #dcdfe6;
  387. border-right: 0;
  388. outline: 0;
  389. }
  390. .input-item .el-input__inner:focus {
  391. border: 1px solid #dcdfe6;
  392. border-right: 0;
  393. outline: 0;
  394. }
  395. .input-item .el-input-group__append {
  396. background-color: #fff;
  397. border-left: 0;
  398. width: 10%;
  399. padding: 0;
  400. }
  401. .input-item .el-input-group__append .el-button {
  402. padding: 0;
  403. }
  404. .input-item .el-input-group__append .el-button {
  405. margin: 0;
  406. }
  407. .batch {
  408. margin: 0 0 20px;
  409. display: inline-block;
  410. }
  411. .batch .el-button {
  412. padding: 9px 15px !important;
  413. }
  414. .item-box{
  415. margin-right: 20px;
  416. }
  417. .item-box .label{
  418. margin-right: 8px;
  419. }
  420. .item-box .symbol{
  421. margin: 0 6px;
  422. }
  423. .form-nickname{
  424. width: 180px;
  425. white-space:nowrap;
  426. overflow:hidden;
  427. text-overflow:ellipsis;
  428. }
  429. .index-video-url{
  430. width: 300px;
  431. }
  432. .index-video-url video{
  433. width: 100%;
  434. }
  435. .index-related-info{
  436. width: 500px;
  437. }
  438. .video-top{
  439. width: 100%;
  440. display: flex;
  441. align-items: flex-start;
  442. box-sizing: border-box;
  443. padding: 20px;
  444. /* opacity: .5; */
  445. background-color: #FFFFFF;
  446. }
  447. .video-top .top-right{
  448. line-height: 26px;
  449. }
  450. .video-top .top-right .top-title{
  451. font-size: 18px;
  452. white-space:nowrap;
  453. overflow:hidden;
  454. text-overflow:ellipsis;
  455. width: 360px;
  456. }
  457. .video-top .top-right .wrapper{
  458. display: flex;
  459. /* align-items: flex-start; */
  460. }
  461. .video-top .top-right .wrapper .to-copy{
  462. /* color: #03C5FF; */
  463. margin-left: 20px;
  464. }
  465. .video-top .top-right .detail-price{
  466. color: #BC0100;
  467. font-size: 18px;
  468. font-family: Microsoft YaHei;
  469. font-weight: bold;
  470. }
  471. /* .atooltip {
  472. background: #FFFFFF !important;
  473. border: none !important;
  474. } */
  475. .el-table th>.cell{
  476. color: #333;
  477. font-weight: bold;
  478. font-size: 14px;
  479. }
  480. .el-table__footer-wrapper, .el-table__header-wrapper{
  481. border-bottom: 1.4px solid #D6D6D6;
  482. }
  483. .price_col{
  484. color: #FF5D05;
  485. }
  486. .redio-center {
  487. display: flex;
  488. align-items: center;
  489. }
  490. .redio-input {
  491. margin-left: -28px;
  492. margin-right: 20px;
  493. }
  494. </style>