home.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <div class="page">
  3. <el-page-header
  4. @back="$router.go(-1)"
  5. :content="curTeamTel"
  6. style="margin-bottom: 20px"
  7. v-if="!isOuter"
  8. ></el-page-header>
  9. <el-header height="40px" style="display: flex; align-items: center">
  10. <el-button
  11. type="primary"
  12. size="normal"
  13. @click="qropen"
  14. plain
  15. v-if="isOuter"
  16. >经销商邀请二维码</el-button
  17. >
  18. <div class="search">
  19. <!-- @keyup.enter.native="teamSearch" -->
  20. <el-input
  21. placeholder="请输入用户名"
  22. v-model.trim="teamValue"
  23. @input="teamSearch"
  24. >
  25. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  26. </el-input>
  27. </div>
  28. </el-header>
  29. <el-container class="course_data">
  30. <el-table
  31. :data="dealerInfo"
  32. border
  33. stripe
  34. highlight-current-row
  35. v-loading="loading"
  36. >
  37. <el-table-column prop="name" label="用户名" align="center">
  38. </el-table-column>
  39. <!-- <el-table-column label="微信ID" align="center" min-width="100px">
  40. <template slot-scope="scope"> {{ scope.row.unionid }} </template>
  41. </el-table-column> -->
  42. <el-table-column label="手机号" align="center">
  43. <template slot-scope="scope"> {{ scope.row.mobile }} </template>
  44. </el-table-column>
  45. <el-table-column
  46. label="TA的团队"
  47. align="center"
  48. style="color: #409eff"
  49. class="outTeam"
  50. v-if="isOuter"
  51. >
  52. <template slot-scope="scope">
  53. <span
  54. @click="toDealerTeam(scope.row)"
  55. style="color: #409eff; cursor: pointer"
  56. >{{ scope.row.statistics.teamAmount }}</span
  57. >
  58. </template>
  59. </el-table-column>
  60. <el-table-column fixed="right" label="操作" width="250" align="center">
  61. <template slot-scope="scope">
  62. <!-- <el-button
  63. type="text"
  64. size="mini"
  65. @click="infoEdit(scope.row, scope.$index)"
  66. >修改信息</el-button
  67. > -->
  68. <el-button
  69. size="mini"
  70. type="text"
  71. @click="dealerPay(scope.row, scope.$index)"
  72. >课程名额修改</el-button
  73. >
  74. </template>
  75. </el-table-column>
  76. </el-table>
  77. <div class="proness">
  78. <el-pagination
  79. background
  80. layout="prev, pager, next"
  81. @current-change="curPageChange()"
  82. :current-page.sync="page.cur"
  83. :page-size="page.size"
  84. :total="page.total"
  85. :hide-on-single-page="false"
  86. >
  87. </el-pagination>
  88. </div>
  89. </el-container>
  90. <el-dialog
  91. title="用户信息修改"
  92. :visible.sync="eldiForm"
  93. width="40%"
  94. :close-on-click-modal="false"
  95. :close-on-press-escape="false"
  96. center
  97. @close="cancleDi"
  98. >
  99. <el-form
  100. :model="dealerForm"
  101. ref="form"
  102. label-width="100px"
  103. :inline="false"
  104. size="normal"
  105. >
  106. <el-form-item label="用户名">
  107. <el-input v-model="dealerForm.name"></el-input>
  108. </el-form-item>
  109. <el-form-item label="绑定微信ID">
  110. <el-input v-model="dealerForm.unionid"></el-input>
  111. </el-form-item>
  112. <el-form-item label="手机号">
  113. <el-input v-model="dealerForm.mobile"></el-input>
  114. </el-form-item>
  115. </el-form>
  116. <span slot="footer">
  117. <el-button @click="cancleDi">取消</el-button>
  118. <el-button type="primary" @click="confirmSave">保存</el-button>
  119. </span>
  120. </el-dialog>
  121. <el-dialog
  122. :visible.sync="qrVisible"
  123. width="400px"
  124. title="经销商邀请二维码"
  125. center
  126. @close="cancleQr"
  127. >
  128. <div id="root" style="display: flex;justify-content: center;" ref="qrCodeUrl"></div>
  129. </el-dialog>
  130. </div>
  131. </template>
  132. <script>
  133. import QRCode from "qrcodejs2";
  134. import { getDealerList } from "../api";
  135. export default {
  136. name: "dealerManage",
  137. components: {},
  138. props: [],
  139. data() {
  140. return {
  141. loading: true,
  142. qrVisible: false,
  143. qrcode: null,
  144. qrcodeStatus: false,
  145. eldiForm: false,
  146. dealerForm: {
  147. id: 0,
  148. name: "",
  149. unionid: "",
  150. mobile: "",
  151. },
  152. curTeamTel: "",
  153. isOuter: false,
  154. page: {
  155. total: 0,
  156. size: 10,
  157. cur: 1,
  158. },
  159. teamValue: "",
  160. dealerInfo: [],
  161. };
  162. },
  163. created() {
  164. this.init();
  165. },
  166. methods: {
  167. qropen() {
  168. this.qrVisible = true;
  169. this.$nextTick(() => {
  170. this.creatQrCode();
  171. });
  172. },
  173. cancleQr() {},
  174. creatQrCode() {
  175. if (!this.qrcodeStatus) {
  176. console.log(`${process.env.BASE_API}/m/#/courseLogin?pid=0`)
  177. this.qrcode = new QRCode(this.$refs.qrCodeUrl, {
  178. text: `${process.env.BASE_API}/m/#/courseLogin?pid=0`, // 需要转换为二维码的内容
  179. width: 300,
  180. height: 300,
  181. colorDark: "#000000",
  182. colorLight: "#ffffff",
  183. correctLevel: QRCode.CorrectLevel.H,
  184. });
  185. this.qrcodeStatus = true;
  186. }
  187. },
  188. //获取经销商列表
  189. getDealerMap(type=1) {
  190. let data = {
  191. page: this.page.cur,
  192. pageSize: this.page.size,
  193. marketable: type,
  194. };
  195. if (this.$route.params.id) {
  196. data.pid = this.$route.params.id;
  197. }
  198. if (this.teamValue) {
  199. data.keyword = this.teamValue;
  200. }
  201. getDealerList(data).then((res) => {
  202. this.loading = false;
  203. this.dealerInfo = res.list;
  204. this.page.cur = res.current;
  205. this.page.total = res.total;
  206. });
  207. },
  208. // 修改经销商信息
  209. confirmSave() {
  210. this.$confirm("确定要修改经销商信息吗?", "提示", {
  211. confirmButtonText: "确认",
  212. cancelButtonText: "取消",
  213. type: "info",
  214. })
  215. .then((action) => {
  216. this.$message({
  217. message: "交易成功!",
  218. type: "success",
  219. showClose: true,
  220. duration: 1500,
  221. });
  222. this.cancleDi();
  223. })
  224. .catch(() => {
  225. this.cancleDi();
  226. });
  227. },
  228. // 取消修改并重置表单
  229. cancleDi() {
  230. let form = {
  231. id: 0,
  232. name: "",
  233. unionid: "",
  234. mobile: "",
  235. };
  236. this.dealerForm = form;
  237. this.eldiForm = false;
  238. },
  239. // 初始化
  240. init() {
  241. if (
  242. this.$route.path.includes("/course/dealerTeam") &&
  243. this.$route.params.id
  244. ) {
  245. this.isOuter = false;
  246. this.curTeamTel = `${this.$route.query.name}的团队`;
  247. this.getDealerMap(1, this.$route.params.id);
  248. } else {
  249. this.isOuter = true;
  250. this.getDealerMap(1);
  251. }
  252. },
  253. // 跳转到我的团队
  254. toDealerTeam(row) {
  255. if (row.statistics.teamAmount != 0) {
  256. this.$router.push({
  257. path: `/course/dealerTeam/${row.id}?name=${row.name}`,
  258. });
  259. } else {
  260. this.$message({
  261. message: "您还没有团队",
  262. type: "warning",
  263. showClose: true,
  264. duration: 3000,
  265. });
  266. }
  267. },
  268. // 搜索
  269. teamSearch() {
  270. this.loading = true;
  271. this.page.cur = 1;
  272. this.getDealerMap();
  273. },
  274. // 切换当前页
  275. curPageChange() {
  276. this.loading = true;
  277. this.getDealerMap();
  278. },
  279. // 打开弹窗修改个人信息
  280. infoEdit(row) {
  281. this.dealerForm = JSON.parse(JSON.stringify(row));
  282. this.eldiForm = true;
  283. },
  284. // 跳转查看交易详情
  285. dealerPay(row) {
  286. this.$router.push(`/course/dealerEdit/${row.id}?name=${row.name}`);
  287. },
  288. },
  289. computed: {},
  290. };
  291. </script>
  292. <style scoped lang="scss">
  293. .page {
  294. padding: 15px;
  295. background-color: #fff;
  296. border-radius: 5px;
  297. .search {
  298. margin-left: 15px;
  299. }
  300. .course_data {
  301. margin-top: 25px;
  302. display: block;
  303. .proness {
  304. margin-top: 20px;
  305. display: flex;
  306. justify-content: center;
  307. }
  308. }
  309. }
  310. </style>