open-list.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('group-list-search', dirname(__DIR__) . '/components');
  4. ?>
  5. <style>
  6. .el-table th>.cell {
  7. color: #333;
  8. font-weight: bold;
  9. font-size: 14px;
  10. }
  11. .el-table__footer-wrapper,
  12. .el-table__header-wrapper {
  13. border-bottom: 1.4px solid #D6D6D6;
  14. },
  15. .default-avatar{
  16. width: 50px;
  17. height: 50px;
  18. border-radius: 50%;
  19. },
  20. .user_img{
  21. position: relative;
  22. margin-right: 8px;
  23. height: 50px;
  24. width: 50px;
  25. }
  26. </style>
  27. <!-- 这个是拼团列表 -->
  28. <div id="app">
  29. <el-card class="box-card">
  30. <div slot="header" class="clearfix">
  31. <span>开团列表</span>
  32. </div>
  33. <com-search @search="toSearch" @download="download" :is-show-order-type="true" :is-show-order-plugin="true">
  34. </com-search>
  35. </el-card>
  36. <div class="table-body">
  37. <template>
  38. <el-table
  39. v-loading="listLoading"
  40. :data="list"
  41. stripe
  42. style="width: 100%">
  43. <el-table-column
  44. fixed
  45. label="开团id"
  46. prop="id"
  47. show-overflow-tooltip
  48. min-width="100"
  49. align="center">
  50. </el-table-column>
  51. <el-table-column label="团长" min-width="150">
  52. <template slot-scope="scope">
  53. <div class="user_img">
  54. <image style="width: 50px;height: 50px; border-radius: 50%;" :src="scope.row.user.avatar_url? scope.row.user.avatar_url:'resources/img/mall/default_avatar_url.png'"></image>
  55. </div>
  56. <div>
  57. <div style="color:#000;">{{scope.row.user.nickname}}</div>
  58. </div>
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="手机号" width="120" align="center">
  62. <template slot-scope="scope">
  63. <div flex="cross:top cross:center">
  64. {{scope.row.user.mobile}}
  65. </div>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="开团时间" width="200" align="center">
  69. <template slot-scope="scope">
  70. <span> {{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="成团时间" width="200" align="center">
  74. <template slot-scope="scope">
  75. <span >{{scope.row.win_time|dateTimeFormat('Y-m-d H:i:s')}}</span>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="实际参团人数" width="120" align="center">
  79. <template slot-scope="scope">
  80. <!-- <span> {{scope.row.groupBuyActive.group_size - scope.row.groupBuyActive.virtual_group_size}}</span>-->
  81. <span> {{scope.row.counts}}</span>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="虚拟拼团人数" width="120" align="center">
  85. <template slot-scope="scope">
  86. <span v-if="scope.row.order_status == 2">
  87. {{scope.row.groupBuyActive.is_virtual && scope.row.groupBuyActive.virtual_group_type == 3 ?
  88. scope.row.groupBuyActive.group_size - scope.row.counts :
  89. scope.row.groupBuyActive.virtual_group_size}}
  90. </span>
  91. <span v-else>-</span>
  92. </template>
  93. </el-table-column>
  94. <el-table-column prop="order_status" label="拼团状态" min-width="120" align="center">
  95. <template slot-scope="scope">
  96. <el-tag effect="dark" type="info" v-if="scope.row.order_status==0">待支付</el-tag>
  97. <el-tag effect="dark" type="" v-if="scope.row.order_status==1">参团中</el-tag>
  98. <el-tag effect="dark" type="success" v-if="scope.row.order_status==2">拼团成功</el-tag>
  99. <el-tag effect="dark" type="warning" v-if="scope.row.order_status==3">拼团失败</el-tag>
  100. <el-tag effect="dark" type="danger" v-if="scope.row.order_status==4">已关闭</el-tag>
  101. </template>
  102. </el-table-column>
  103. <el-table-column label="操作" min-width="260" align="center">
  104. <template slot-scope="scope">
  105. <el-button v-if="scope.row.order_status==1||scope.row.order_status==2" @click="groupMemberList(scope.row)" type="text" size="small">拼团成员</el-button>
  106. <el-button v-if="scope.row.order_status==1" @click="finish(scope.row)" type="text" size="small">结束拼团</el-button>
  107. </template>
  108. </el-table-column>
  109. </el-table>
  110. <div flex="main:right cross:center" style="margin-top: 20px;">
  111. <el-pagination v-if="pagination" :page-size="pagination.defaultPageSize"
  112. style="display: inline-block;float: right;" background @current-change="pageChange"
  113. layout="prev, pager, next" :total="pagination.totalCount">
  114. </el-pagination>
  115. </div>
  116. </template>
  117. </div>
  118. <!-- 拼团成员列表弹窗组件 -->
  119. <el-dialog title="拼团成员" :visible.sync="dialogFormVisible">
  120. <el-table :data="memberList" v-loading="dialogLoading">
  121. <el-table-column label="用户头像" width="150" align="center">
  122. <template slot-scope="scope">
  123. <div class="user_img">
  124. <image style="width: 50px;height: 50px; border-radius: 50%;" :src="scope.row.user.avatar_url? scope.row.user.avatar_url:'resources/img/mall/default_avatar_url.png'"></image>
  125. </div>
  126. </template>
  127. </el-table-column>
  128. <el-table-column property="user.nickname" label="昵称" width="100" align="center"></el-table-column>
  129. <el-table-column property="is_creator" label="角色" width="80" align="center">
  130. <template slot-scope="scope">
  131. <span v-html="scope.row.is_commander=='1'?'团长':'团员'"></span>
  132. </template>
  133. </el-table-column>
  134. <el-table-column property="total_price" label="订单金额" width="100" align="center">
  135. <template slot-scope="scope">
  136. <span>¥{{scope.row.group_buy_price*scope.row.num}}</span>
  137. </template>
  138. </el-table-column>
  139. <el-table-column label="状态" width="100" align="center">
  140. <template slot-scope="scope">
  141. <el-tag effect="dark" type="info" v-if="scope.row.order_status==0">待支付</el-tag>
  142. <el-tag effect="dark" type="" v-if="scope.row.order_status==1">参团中</el-tag>
  143. <el-tag effect="dark" type="success" v-if="scope.row.order_status==2">拼团成功</el-tag>
  144. <el-tag effect="dark" type="warning" v-if="scope.row.order_status==3">拼团失败</el-tag>
  145. <el-tag effect="dark" type="danger" v-if="scope.row.order_status==4">已关闭</el-tag>
  146. </template>
  147. </el-table-column>
  148. <el-table-column label="下单时间" width="150" align="center">
  149. <template slot-scope="scope">
  150. <span> {{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}</span>
  151. </template>
  152. </el-table-column>
  153. <el-table-column property="order_id" label="操作" align="center">
  154. <template slot-scope="scope">
  155. <el-button v-if="scope.row.order_status==2" @click="toOrderDetail(scope.row.order_id)" type="text" size="small">订单详情</el-button>
  156. </template>
  157. </el-table-column>
  158. </el-table>
  159. </el-dialog>
  160. </div>
  161. <script>
  162. const app = new Vue({
  163. el: '#app',
  164. data() {
  165. return {
  166. listLoading:false,
  167. list: [],
  168. pagination: {total: 0},
  169. loading: false,
  170. dialogLoading:false,
  171. group_buy_active_id : '', //拼团活动id
  172. pageCount: 0, //总的页面数
  173. current_page: 1, //默认显示第一页
  174. search : {}, //这个是搜索来的字段
  175. memberList: [],
  176. dialogFormVisible: false,
  177. }
  178. },
  179. methods: {
  180. // 0.1 点击搜索--这个也是要发请求
  181. toSearch(e){
  182. console.log('e==',e);
  183. let searchData = e;
  184. let others = {group_buy_active_id : this.group_buy_active_id}
  185. let search={};
  186. searchData.nickname?search['nickname']=searchData.nickname:'';
  187. searchData.begin_time?search['begin_time']=searchData.begin_time:'';
  188. searchData.end_time?search['end_time']=searchData.end_time:'';
  189. searchData.order_status=="选择拼团状态"?'':search['order_status']=searchData.order_status;
  190. this.current_page = 1;
  191. this.search = search;
  192. this.loadData(this.current_page,others,search);
  193. },
  194. download(e){
  195. let searchData = e;
  196. let others = {group_buy_active_id : this.group_buy_active_id}
  197. // 创建一个search请求对象--可以用es6方法const {a1,b1} = a; const b ={a1,b1}
  198. let search={};
  199. searchData.nickname?search['nickname']=searchData.nickname:'';
  200. searchData.begin_time?search['begin_time']=searchData.begin_time:'';
  201. searchData.end_time?search['end_time']=searchData.end_time:'';
  202. searchData.status=="选择拼团状态"?'':search['status']=searchData.status;
  203. this.search = search;
  204. this.toDownload(others,search);
  205. },
  206. toDownload(others,search) {
  207. request({
  208. params: {
  209. r: 'group-buy/default/open-list',
  210. ...others,
  211. ...search
  212. },
  213. method: 'GET',
  214. }).then(e => {
  215. let res = e.data;
  216. if (res.code == 0) {
  217. console.log(res.data.url);
  218. window.open(res.data.url, '_blank').location;
  219. }else{
  220. this.$message.error(res.msg);
  221. }
  222. }).catch(e => {
  223. });
  224. },
  225. // 页面跳转
  226. toPageAdd() {
  227. navigateTo({
  228. r: 'group-buy/index/add',
  229. })
  230. },
  231. // 跳转拼团订单列表
  232. toOrderList() {
  233. navigateTo({
  234. r: 'group-buy/order/list',
  235. })
  236. },
  237. // 跳转拼团订单列表
  238. toGroupList(){
  239. navigateTo({
  240. r: 'group-buy/group/list',
  241. })
  242. },
  243. // 跳转到订单详情
  244. toOrderDetail(order_id){
  245. navigateTo({
  246. r: 'mall/order/detail',
  247. id:order_id, //直接跳转到订单详情页,但是要确保获取时字段统一
  248. })
  249. },
  250. //页面数变化,获取新的数据--获取到页面数,发请求就完事了
  251. changePagination(e) {
  252. console.log(e);
  253. this.current_page = e; //当前页
  254. let others = {group_buy_active_id : this.group_buy_active_id}
  255. this.loadData(this.current_page,others,this.search);
  256. },
  257. // 结束该团
  258. finish(row) {
  259. this.loading = true;
  260. request({
  261. params: {
  262. r: 'group-buy/default/finish',
  263. open_group_id: row.id
  264. },
  265. method: 'get',
  266. }).then(e => {
  267. let res = e.data;
  268. this.listLoading = false;
  269. if (res.code === 0) {
  270. let others = {group_buy_active_id : this.group_buy_active_id}
  271. this.loadData(this.current_page,others,this.search);
  272. this.$message.success(res.msg);
  273. } else {
  274. this.$message.error(res.msg);
  275. }
  276. }).catch(e => {
  277. });
  278. },
  279. // 请求获取数据--获取活动的开团列表
  280. loadData(page,others,search) {
  281. this.listLoading = true;
  282. request({
  283. params: {
  284. r: 'group-buy/default/open-list',
  285. page: page,
  286. ...others,
  287. ...search
  288. },
  289. method: 'get',
  290. }).then(e => {
  291. let res = e.data;
  292. this.listLoading = false;
  293. if (res.code === 0) {
  294. this.list = res.data.list;
  295. this.pageCount = res.data.pagination.page_count; //返回了总的页面数
  296. this.pagination = res.data.pagination; //拿到关于页码页容量的数据
  297. } else {
  298. this.$message.error(res.msg);
  299. }
  300. }).catch(e => {
  301. });
  302. },
  303. // 获取该团下的拼团成员列表
  304. groupMemberList(row) {
  305. this.dialogFormVisible = true;
  306. this.dialogLoading = true;
  307. request({
  308. params: {
  309. r: 'group-buy/default/group-buy-team',
  310. open_group_id : row.open_group_id,
  311. group_buy_active_id : row.group_buy_active_id,
  312. commander_id : row.commander_id,
  313. },
  314. method: 'get',
  315. }).then(e => {
  316. let res = e.data;
  317. this.dialogLoading = false;
  318. if (res.code === 0) {
  319. this.memberList = res.data.list;
  320. } else {
  321. this.$message.error(res.msg);
  322. }
  323. }).catch(e => {
  324. });
  325. },
  326. pageChange(page) {
  327. let others = {group_buy_active_id : this.group_buy_active_id}
  328. this.loadData(page,others,this.search);
  329. },
  330. formatStatus: function (row) {
  331. switch (row.status) {
  332. case '0':
  333. return '全部';
  334. case '1':
  335. return '开团中';
  336. case '2':
  337. return '已结束';
  338. default:
  339. return '未知';
  340. }
  341. },
  342. },
  343. // 加载的时候获取到列表页
  344. created(){
  345. // 获取到活动id
  346. if(getQuery('group_buy_active_id')){
  347. this.group_buy_active_id = getQuery('group_buy_active_id');
  348. }
  349. },
  350. mounted(){
  351. // 数据初始化
  352. this.current_page = 1;
  353. this.pageCount = 0;
  354. // 默认是拿到对应拼团id下的列表数据
  355. let others = {group_buy_active_id : this.group_buy_active_id}
  356. this.loadData(this.current_page,others,this.search);
  357. },
  358. })
  359. </script>