index.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('com-share-pop');
  4. ?>
  5. <div id="app" v-cloak>
  6. <el-card shadow="never" style="border:0;min-width: 1000px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  7. <div slot="header">
  8. <span>商户列表</span>
  9. <el-button type="primary" size="small" style="padding: 9px 15px !important; float: right; position: relative; bottom: 8px;" @click="addStore">添加商户</el-button>
  10. </div>
  11. <div class="table-body">
  12. <el-alert style="margin-bottom:20px;" type="info" title="商户管理端登录入口链接:" :closable="false">
  13. <template>
  14. <span id="target">{{store_login_url}}</span>
  15. <el-button type="text" id="copy_btn" data-clipboard-action="copy" data-clipboard-target="#target" size="mini">复制链接 </el-button>
  16. </template>
  17. </el-alert>
  18. <div style="padding-bottom: 20px;">
  19. <div class="flex">
  20. <div class="flex" style="margin-right: 20px;">
  21. <div class="input-title" style="flex-shrink: 0;">商户名称</div>
  22. <el-input size="small" style="width: 130px;" placeholder="请输入商户名称" v-model="searchData.store_name"> </el-input>
  23. </div>
  24. <div class="flex" style="margin-right: 20px;">
  25. <div class="input-title" style="flex-shrink: 0;">姓名</div>
  26. <el-input size="small" style="width: 130px;" placeholder="请输入姓名" v-model="searchData.storeowner">
  27. </el-input>
  28. </div>
  29. <div class="flex" style="margin-right: 20px;">
  30. <div class="input-title" style="flex-shrink: 0;">绑定会员</div>
  31. <el-input size="small" style="width: 130px;" placeholder="请输入会员名称" v-model="searchData.nickname">
  32. </el-input>
  33. </div>
  34. <div class="item-box" flex="dir:left cross:center">
  35. <div class="label">商户状态</div>
  36. <el-select v-model="searchData.status" @change='searchs' class="select" size="small" style="width: 130px;">
  37. <el-option :key="0" label="全部" :value="0"></el-option>
  38. <el-option :key="1" label="正常" :value="1"></el-option>
  39. <el-option :key="2" label="过期" :value="2"></el-option>
  40. <el-option :key="3" label="禁用" :value="3"></el-option>
  41. </el-select>
  42. </div>
  43. <el-button style="padding: 9px 15px !important;" size="small" type="primary" @click="searchs">搜索</el-button>
  44. <el-button type="warning" @click="clereSearch" v-if="searchData.store_name || searchData.storeowner || searchData.nickname || searchData.cate_id || searchData.status" style="padding: 9px 15px !important;">清除搜索条件</el-button>
  45. </div>
  46. </div>
  47. <el-table :data="list" stripe v-loading="loading" size="small" style="margin-bottom: 15px; width: 100%">
  48. <!-- <el-table-column prop="id" label="商户ID" width="100"></el-table-column> -->
  49. <el-table-column label="商户名称" width="200" prop="store_name">
  50. <template slot-scope="scope">
  51. <com-image style="float: left;margin-right: 10px;" mode="aspectFill" :src="scope.row.logo_img"></com-image>
  52. <div>{{scope.row.store_name}}</div>
  53. <div>{{scope.row.shop_mobile}}</div>
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="会员" width="150" align="center">
  57. <template slot-scope="scope">
  58. <com-image style="float: left;margin-right: 5px;" mode="aspectFill" :src="scope.row.avatar_url"></com-image>
  59. <div>{{scope.row.nickname}}</div>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="姓名" prop="shop_owner" width="120" align="center">
  63. <template slot-scope="scope">
  64. <div>{{scope.row.shop_owner}}</div>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="商户有效期" prop="expire_time" width="300" align="center">
  68. <template slot-scope="scope">
  69. <div>
  70. <samp v-if="scope.row.expire_time==0">无限期</samp>
  71. <samp v-else>{{scope.row.expire_time|dateTimeFormat('Y-m-d H:i:s')}} 到期</samp>
  72. </div>
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="" prop="" width="300" align="center">
  76. <template slot="header">
  77. 金额
  78. <el-tooltip placement="top">
  79. <div slot="content">总收入:商户累计收入<br />当前余额:商户当前余额</div>
  80. <i class="el-icon-question grid-icon"></i>
  81. </el-tooltip>
  82. </template>
  83. <template slot-scope="scope">
  84. <div>
  85. 累计收入:<span style="color: #409EFF;">{{scope.row.total_money || 0}}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  86. 当前余额:<span style="color: #409EFF;">{{scope.row.balance || 0}}</span>
  87. </div>
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="会员总数" prop="user_nums" width="100" align="center">
  91. <template slot-scope="scope">
  92. <div>
  93. {{scope.row.user_nums}}
  94. </div>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="状态" prop="store_status" width="100" align="center">
  98. <template slot-scope="scope">
  99. <div>
  100. <span>{{storeStatus[scope.row.store_status]}}</span>
  101. </div>
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="创建时间" prop="user_count" width="300" align="center">
  105. <template slot-scope="scope">
  106. <div>
  107. {{scope.row.created_at | dateTimeFormat('Y-m-d H:i:s')}}
  108. </div>
  109. </template>
  110. </el-table-column>
  111. <el-table-column label="操作" style="width: 100px;" fixed="right" align="center">
  112. <template slot-scope="scope">
  113. <el-button type="text" size="small" @click="goToDetail(scope.row.id)">详情</el-button>
  114. <com-share-pop :url="scope.row.promotion_code">
  115. <template slot="share-button" slot-scope="data">
  116. <el-button circle size="mini" type="text" @click="showPromotionCode(scope.row.id, data.show)"> 推广码 </el-button>
  117. </template>
  118. </com-share-pop>
  119. <el-button v-if="scope.row.store_status==1" type="text" size="small" @click="switchStatus(scope.$index, 3)">禁用</el-button>
  120. <el-button v-else-if="scope.row.store_status==3" type="text" size="small" @click="switchStatus(scope.$index, 1)">启用</el-button>
  121. <el-button type="text" size="small" @click="storeDelete(scope.row)">删除</el-button>
  122. </template>
  123. </el-table-column>
  124. </el-table>
  125. <div style="text-align: right;margin: 20px 0;">
  126. <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
  127. </div>
  128. </div>
  129. </el-card>
  130. </div>
  131. <script src="/resources/unpkg/clipboard@1.0.0/dist/clipboard.min.js"></script>
  132. <script>
  133. const app = new Vue({
  134. el: '#app',
  135. data: {
  136. searchData: {
  137. cate_id: 0,
  138. nickname: '',
  139. storeowner: '',
  140. store_name: '',
  141. status: 0,
  142. },
  143. currPage: 1,
  144. pageCount: 0,
  145. loading: false,
  146. list: [],
  147. dialogLoading: false,
  148. // exportList: [],
  149. categorys: [],
  150. storeStatus: {
  151. 1: '正常',
  152. 2: '过期',
  153. 3: '禁用'
  154. },
  155. store_login_url: '', // 商户登录 url
  156. shareData: {
  157. url: "", //链接
  158. img: "", //二维码
  159. qrcode_filename: '', // 二维码文件名
  160. },
  161. },
  162. mounted() {
  163. this.loadData();
  164. },
  165. methods: {
  166. searchs() {
  167. this.currPage = 1;
  168. this.loadData();
  169. },
  170. clereSearch() {
  171. this.searchData.cate_id = 0;
  172. this.searchData.nickname = '';
  173. this.searchData.storeowner = '';
  174. this.searchData.store_name = '';
  175. this.searchData.status = 0;
  176. this.currPage = 1;
  177. this.loadData();
  178. },
  179. // 打开推广码弹窗
  180. showPromotionCode(id, fun) {
  181. // this.store_login_url = this.store_login_url;
  182. setTimeout(() => {
  183. fun();
  184. }, 300)
  185. },
  186. // 禁用 / 启用商户
  187. switchStatus(index, status) {
  188. let self = this;
  189. let tip = status == 1 ? '启用' : '禁用';
  190. let mch_id = self.list[index].id;
  191. self.$confirm(tip + '该商户, 是否继续?', '提示', {
  192. confirmButtonText: '确定',
  193. cancelButtonText: '取消',
  194. type: 'warning'
  195. }).then(() => {
  196. self.loading = true;
  197. request({
  198. params: {
  199. r: 'mch/store/switch-status',
  200. },
  201. data: {
  202. mch_id: mch_id,
  203. status: status,
  204. },
  205. method: 'post'
  206. }).then(e => {
  207. self.loading = false;
  208. if (e.data.code == 0) {
  209. this.list[index].store_status = status;
  210. self.$message.success('操作成功');
  211. } else {
  212. self.$message.error('操作失败');
  213. }
  214. }).catch(e => {
  215. self.loading = false;
  216. console.log(e);
  217. self.$message.error('网络错误');
  218. });
  219. }).catch(() => {
  220. });
  221. },
  222. storeDelete(row) {
  223. let self = this;
  224. self.$confirm('删除该商户, 是否继续?', '提示', {
  225. confirmButtonText: '确定',
  226. cancelButtonText: '取消',
  227. type: 'warning'
  228. }).then(() => {
  229. self.listLoading = true;
  230. request({
  231. params: {
  232. r: 'mch/store/del',
  233. },
  234. method: 'post',
  235. data: {
  236. id: row.id,
  237. }
  238. }).then(e => {
  239. self.listLoading = false;
  240. console.log(111,e.data.code)
  241. if (e.data.code === 0) {
  242. self.$message.success(e.data.msg);
  243. this.loadData();
  244. } else {
  245. self.$message.error(e.data.msg);
  246. }
  247. }).catch(e => {
  248. console.log(e.message);
  249. });
  250. }).catch(() => {
  251. self.$message.info('已取消删除')
  252. });
  253. },
  254. loadData() {
  255. this.loading = true;
  256. request({
  257. params: {
  258. r: 'mch/store/index',
  259. page: this.currPage,
  260. ...this.searchData,
  261. },
  262. method: 'get',
  263. }).then(e => {
  264. this.loading = false;
  265. if (e.data.code == 0) {
  266. this.list = e.data.data.list;
  267. this.store_login_url = e.data.data.store_login_url;
  268. this.pageCount = e.data.data.page_count;
  269. // this.exportList = e.data.data.export_list;
  270. this.edit_status = e.data.data.edit_status;
  271. this.categorys = e.data.data.cate_list;
  272. } else {
  273. this.$message.error(e.data.msg);
  274. }
  275. }).catch(e => {
  276. this.loading = false;
  277. });
  278. },
  279. pagination(currentPage) {
  280. let self = this;
  281. self.currPage = currentPage;
  282. self.loadData();
  283. },
  284. addStore(id) {
  285. navigateTo({
  286. r: 'mch/store/storage',
  287. });
  288. },
  289. // 跳转商户详情页
  290. goToDetail(id) {
  291. navigateTo({
  292. r: 'mch/store/detail',
  293. mch_id: id,
  294. });
  295. },
  296. }
  297. });
  298. var clipboard = new ClipboardJS('#copy_btn');
  299. var self = this;
  300. clipboard.on('success', function(e) {
  301. self.ELEMENT.Message.success('复制成功');
  302. e.clearSelection();
  303. });
  304. clipboard.on('error', function(e) {
  305. self.ELEMENT.Message.success('复制失败,请手动复制');
  306. });
  307. </script>
  308. <style>
  309. .el-tabs__header {
  310. font-size: 16px;
  311. }
  312. .table-body {
  313. padding: 20px;
  314. background-color: #fff;
  315. }
  316. .input-item {
  317. width: 250px;
  318. margin-right: 40px;
  319. }
  320. .input-item .el-input__inner {
  321. border-right: 0;
  322. }
  323. .input-item .el-input__inner:hover {
  324. border: 1px solid #dcdfe6;
  325. border-right: 0;
  326. outline: 0;
  327. }
  328. .input-item .el-input__inner:focus {
  329. border: 1px solid #dcdfe6;
  330. border-right: 0;
  331. outline: 0;
  332. }
  333. .input-item .el-input-group__append {
  334. background-color: #fff;
  335. border-left: 0;
  336. width: 10%;
  337. padding: 0;
  338. }
  339. .input-item .el-input-group__append .el-button {
  340. padding: 0;
  341. }
  342. .input-item .el-input-group__append .el-button {
  343. margin: 0;
  344. }
  345. .table-body {
  346. padding: 20px;
  347. background-color: #fff;
  348. }
  349. .table-body .el-button {
  350. padding: 0 !important;
  351. border: 0;
  352. margin: 0 5px;
  353. }
  354. .input-item {
  355. width: 250px;
  356. margin: 0 0 20px;
  357. display: inline-block;
  358. }
  359. .input-item .el-input__inner {
  360. border-right: 0;
  361. }
  362. .input-item .el-input__inner:hover {
  363. border: 1px solid #dcdfe6;
  364. border-right: 0;
  365. outline: 0;
  366. }
  367. .input-item .el-input__inner:focus {
  368. border: 1px solid #dcdfe6;
  369. border-right: 0;
  370. outline: 0;
  371. }
  372. .input-item .el-input-group__append {
  373. background-color: #fff;
  374. border-left: 0;
  375. width: 10%;
  376. padding: 0;
  377. }
  378. .input-item .el-input-group__append .el-button {
  379. padding: 0;
  380. }
  381. .input-item .el-input-group__append .el-button {
  382. margin: 0;
  383. }
  384. .batch {
  385. margin: 0 0 20px;
  386. display: inline-block;
  387. }
  388. .batch .el-button {
  389. padding: 9px 15px !important;
  390. }
  391. .el-table th>.cell {
  392. color: #333;
  393. font-weight: bold;
  394. font-size: 14px;
  395. }
  396. .el-table__footer-wrapper,
  397. .el-table__header-wrapper {
  398. border-bottom: 1.4px solid #D6D6D6;
  399. }
  400. .el-table .el-button {
  401. padding: 0 !important;
  402. border: 0;
  403. margin: 0 5px;
  404. }
  405. #app .copy .el-input-group__append {
  406. background-color: #409EFF;
  407. border-color: #409EFF;
  408. padding: 0 10px;
  409. }
  410. #app .table-body .copybtn {
  411. color: #fff;
  412. padding: 0 30px;
  413. }
  414. .el-alert {
  415. padding: 0;
  416. padding-left: 5px;
  417. padding-bottom: 5px;
  418. }
  419. .el-alert--info .el-alert__description {
  420. color: #606266;
  421. }
  422. .el-alert .el-button {
  423. margin-left: 20px;
  424. }
  425. .el-alert__content {
  426. display: flex;
  427. align-items: center;
  428. }
  429. .table-body .el-alert__title {
  430. margin-top: 5px;
  431. font-weight: 400;
  432. }
  433. .el-table th>.cell {
  434. color: #333;
  435. font-weight: bold;
  436. font-size: 14px;
  437. }
  438. .el-table__footer-wrapper,
  439. .el-table__header-wrapper {
  440. border-bottom: 1.4px solid #D6D6D6;
  441. }
  442. .item-box {
  443. margin-right: 20px;
  444. }
  445. .flex {
  446. display: flex;
  447. align-items: center;
  448. }
  449. .input-title {
  450. margin-right: 15px;
  451. }
  452. .item-box .label {
  453. margin-right: 8px;
  454. }
  455. .com-share-pop {
  456. display: inline-block;
  457. }
  458. .grid-icon {
  459. color: #999;
  460. cursor: pointer;
  461. font-size: 18px;
  462. }
  463. </style>