cart.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ?>
  4. <style>
  5. .app-share {
  6. padding-top: 12px;
  7. border-top: 1px solid #e2e2e2;
  8. margin-top: -20px;
  9. }
  10. .app-share .app-share-bg {
  11. position: relative;
  12. width: 310px;
  13. height: 360px;
  14. background-repeat: no-repeat;
  15. background-size: contain;
  16. background-position: center
  17. }
  18. .app-share .app-share-bg .title {
  19. width: 160px;
  20. height: 29px;
  21. line-height: 1;
  22. word-break: break-all;
  23. text-overflow: ellipsis;
  24. display: -webkit-box;
  25. -webkit-box-orient: vertical;
  26. -webkit-line-clamp: 2;
  27. overflow: hidden;
  28. }
  29. .app-share .app-share-bg .pic-image {
  30. background-repeat: no-repeat;
  31. background-position: 0 0;
  32. background-size: cover;
  33. width: 160px;
  34. height: 130px;
  35. }
  36. .el-card__header {
  37. padding: 8px 20px;
  38. }
  39. .el-form-item--mini.el-form-item, .el-form-item--small.el-form-item {
  40. margin: 5px;
  41. }
  42. .el-form-item__content, .el-form-item__label{
  43. margin-top: 10px;
  44. }
  45. </style>
  46. <div id="app" v-cloak>
  47. <el-card class="box-card" v-loading="loading" shadow="never" style="border:0;min-width: 1200px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  48. <div class="form_box">
  49. <template>
  50. <el-card>
  51. <div style="display: flex;align-items: center;padding-bottom: 10px;border-bottom: 1px solid #E4E7ED;margin:10px 0 20px 15px;font-size:18px;">
  52. <div style="width: 5px;height: 20px;background-color: #409eff;margin-right: 5px;"></div>
  53. <div>购物车设置</div>
  54. </div>
  55. <el-form :model="ruleForm" size="small" ref="ruleForm" label-width="150px">
  56. <el-tabs v-model="activeName">
  57. <el-row>
  58. <el-col :span="24">
  59. <el-form-item label-width="180px" label="使用商城购物车">
  60. <el-col :span="14">
  61. <el-checkbox-group v-model="ruleForm.cart.cart_type.value">
  62. <el-checkbox v-for="(value,key) in cart_list" v-if="key == 1 || (key == 2 && ruleForm.cart.install_o2o == 1)" :key="key" :label="key" @change="checked => HandleChangeChecked(checked, key)">{{value}}</el-checkbox>
  63. </el-checkbox-group>
  64. </el-col>
  65. </el-form-item>
  66. </el-col>
  67. </el-row>
  68. <!-- <el-card style="margin-top: 20px;"> -->
  69. <div style="display: flex;align-items: center;padding-bottom: 10px;border-bottom: 1px solid #E4E7ED;margin:10px 0 20px 15px;font-size:18px;">
  70. <div style="width: 5px;height: 20px;background-color: #409eff;margin-right: 5px;"></div>
  71. <div>名称设置</div>
  72. <span class="tips-text" style="padding-left:10px;line-height:24px;color:red;margin-top:5px;">注意:购物车设置同时勾选主商城商品和o2o商品才生效</span>
  73. </div>
  74. <el-row>
  75. <el-col :span="16">
  76. <el-form-item label="主商城购物车名称:" >
  77. <el-input v-model="ruleForm.cart.cart_name.value[1]['name']" style="width: 200px;"></el-input>
  78. <el-switch v-model="ruleForm.cart.cart_name.value[1]['is_show']" :active-value="'1'" :inactive-value="'0'"></el-switch>
  79. <span class="tips-text">关闭:前端则显示默认名称;开启:前端显示自定义名称。</span>
  80. </el-form-item>
  81. <el-form-item label="o2o门店购物车名称:" >
  82. <el-input v-model="ruleForm.cart.cart_name.value[2]['name']" style="width: 200px;"></el-input>
  83. <el-switch v-model="ruleForm.cart.cart_name.value[2]['is_show']" :active-value="'1'" :inactive-value="'0'"></el-switch>
  84. <span class="tips-text">关闭:前端则显示默认名称;开启:前端显示自定义名称。</span>
  85. </el-form-item>
  86. </el-col>
  87. </el-row>
  88. <!-- </el-card> -->
  89. </el-tabs>
  90. <el-button :loading="btnLoading" class="button-item" type="primary" style="margin-top: 24px;" @click="submit" size="small">保存
  91. </el-button>
  92. </el-form>
  93. </el-card>
  94. </template>
  95. </div>
  96. </el-card>
  97. </div>
  98. <script src="<?= Yii::$app->request->baseUrl ?>/resources/unpkg/vuedraggable@2.18.1/dist/vuedraggable.umd.min.js"></script>
  99. <script>
  100. const app = new Vue({
  101. el: '#app',
  102. data() {
  103. return {
  104. loading: false,
  105. btnLoading: false,
  106. params: {},
  107. pay_after_link_show: '我的订单',
  108. defaultTabs: [
  109. {"name":"mall"}
  110. ],
  111. activeName: 'mall_cart',
  112. cart_list: {
  113. 1: '主商城商品',
  114. 2: 'o2o门店商品',
  115. },
  116. ruleForm: {
  117. cart: {
  118. install_o2o: 0,
  119. cart_type: {
  120. 'title': '所选商城购物车',
  121. 'value': ['1'],
  122. },
  123. cart_name: {
  124. 'title': '购物车别名',
  125. 'value':[
  126. ],
  127. },
  128. },
  129. },
  130. keyword: ''
  131. }
  132. },
  133. mounted: function() {
  134. this.loadData();
  135. },
  136. methods: {
  137. loadData() {
  138. if(this.loading === true) return;
  139. this.loading = true;
  140. request({
  141. params: {
  142. r: 'mall/setting/edit',
  143. type: 'mall_cart',
  144. },
  145. method: 'get'
  146. }).then(e => {
  147. this.loading = false;
  148. if (e.data.code == 0) {
  149. if(e.data.data) {//有选中的
  150. var data = e.data.data;
  151. Object.keys(this.ruleForm).forEach((key) => {
  152. Object.keys(this.ruleForm[key]).forEach((k) => {
  153. if (data[key][k]) {
  154. var dataValue = data[key][k].value;
  155. if(data[key][k].value!=null){
  156. if (typeof dataValue == 'string' && (dataValue.indexOf("{") !== -1 || dataValue.indexOf("[") !== -1)) {
  157. // 将json字符串转为对象
  158. if (k == 'pay_after_link') {
  159. var pay_after_link = JSON.parse(data[key][k].value);
  160. this.pay_after_link_show = pay_after_link.params.title;
  161. this.ruleForm[key][k].value = data[key][k].value;
  162. } else {
  163. this.ruleForm[key][k].value = JSON.parse(data[key][k].value);
  164. }
  165. }else{
  166. this.ruleForm[key][k].value = data[key][k].value;
  167. }
  168. }
  169. }
  170. });
  171. });
  172. this.ruleForm.cart.install_o2o=e.data.data.cart.install_o2o;
  173. this.cart_list = e.data.data.cart_list;
  174. if (e.data.data.cart.install_o2o == 0) {
  175. Object.keys(this.ruleForm.cart.cart_type.value).forEach((key) => {
  176. if (this.ruleForm.cart.cart_type.value[key] == 2) {
  177. this.ruleForm.cart.cart_type.value.splice(key, 1);
  178. }
  179. });
  180. }
  181. }
  182. }
  183. console.log(this.ruleForm)
  184. }).catch(e => {
  185. this.loading = false;
  186. })
  187. },
  188. submit() {
  189. if (this.ruleForm.cart.cart_type.value.length < 1) {
  190. this.$message.error('最少需要选中一个购物车');
  191. return false;
  192. }
  193. this.btnLoading = true;
  194. this.$request({
  195. params: {
  196. r: 'mall/setting/edit',
  197. },
  198. method: 'post',
  199. data: {
  200. setting: this.ruleForm,
  201. },
  202. }).then(e => {
  203. this.btnLoading = false;
  204. if (e.data.code === 0) {
  205. this.$message.success(e.data.msg);
  206. } else {
  207. this.$message.error(e.data.msg);
  208. }
  209. this.loading = false;
  210. this.settingPop = false;
  211. }).catch(e => {
  212. this.btnLoading = false;
  213. this.loading = false;
  214. this.settingPop = false;
  215. });
  216. },
  217. HandleChangeChecked(val, index) {
  218. this.$forceUpdate();
  219. },
  220. }
  221. });
  222. </script>