invited.blade.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. @extends('layouts.base')
  2. @section('title', '会员邀请码')
  3. @section('content')
  4. <link href="{{static_url('yunshop/css/total.css')}}" media="all" rel="stylesheet" type="text/css" />
  5. <style scoped>
  6. /* 设置input宽度 */
  7. .input-w {
  8. width: 180px;
  9. margin-right: 20px;
  10. }
  11. .input-w-s {
  12. width: 225px;
  13. }
  14. .el-input__inner {
  15. /* height: 35px; */
  16. border: 1px solid #ccc;
  17. }
  18. .input_box,
  19. .select_box,
  20. .button_box {
  21. display: inline-block;
  22. margin-bottom: 13px;
  23. }
  24. .button_box {
  25. margin-left: 15px;
  26. }
  27. .input_box {
  28. padding-left: 14px;
  29. }
  30. /* 邀请码列表 */
  31. .vue-title-content span {
  32. opacity: .6;
  33. margin-left: 14px;
  34. }
  35. .el-table .cell {
  36. color: #333;
  37. font-family: inherit;
  38. }
  39. .el-table td div {
  40. font-family: "微软雅黑";
  41. font-weight: 400;
  42. }
  43. /* 无数据显示 */
  44. .not {
  45. width: 40px;
  46. height: 22px;
  47. color: #fff;
  48. line-height: 22px;
  49. text-align: center;
  50. margin: 22px auto;
  51. cursor: default;
  52. font-weight: 600;
  53. font-family: "微软雅黑";
  54. background-color: #999999;
  55. }
  56. .marTop {
  57. margin-top: 5px;
  58. line-height: 0px;
  59. }
  60. .marTop>img {
  61. margin-bottom: 15px;
  62. }
  63. /* 分页 */
  64. .pagination-right {
  65. margin: 50px auto;
  66. text-align: center;
  67. }
  68. .input_btn {
  69. height: 42px;
  70. border-radius: 4px;
  71. }
  72. /* 搜索 */
  73. .search_box {
  74. width: 102px;
  75. }
  76. /* 导出 */
  77. .export_box {
  78. width: 102px;
  79. color: #29ba9c;
  80. border: solid 1px #29ba9c;
  81. }
  82. [v-cloak] {
  83. display: none;
  84. }
  85. </style>
  86. <div class="all">
  87. <div id="app" v-cloak>
  88. <div class="total-head">
  89. <el-form>
  90. <!-- 会员邀请码 -->
  91. <el-form-item>
  92. <div class="vue-title">
  93. <div class="vue-title-left"></div>
  94. <div class="vue-title-content">会员邀请码</div>
  95. </div>
  96. </el-form-item>
  97. <!-- 邀请码输入 -->
  98. <el-form-item>
  99. <div class="input_box">
  100. <el-input clearable class="input-w" v-model="invite.code" placeholder="邀请码"></el-input>
  101. <el-input clearable class="input-w input-w-s" v-model="invite.id" @input="invite.id=invite.id.replace(/[^\d]/g,'')" placeholder="可搜索邀请人id或被邀请人id">
  102. </el-input>
  103. </div>
  104. <div class="select_box">
  105. <!-- 日期和时间 -->
  106. <el-date-picker value-format="timestamp"  type="datetimerange" v-model="invite.date" align="right" unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="invite.pickerOptions">
  107. </el-date-picker>
  108. </div>
  109. <div class="button_box">
  110. <el-button @click="searchBtn" @keyup.enter="searchBtn" type="primary" class="input_btn search_box">搜索</el-button>
  111. <el-button @click="deriveEvent" class="input_btn export_box">导出</el-button>
  112. </div>
  113. </el-form-item>
  114. </el-form>
  115. </div>
  116. <!-- 邀请码列表 -->
  117. <div class="total-floo" style="padding-bottom:1px;">
  118. <div class="vue-title">
  119. <div class="vue-title-left"></div>
  120. <div class="vue-title-content">邀请码记录<span>总数:&nbsp;[[total]]</span></div>
  121. </div>
  122. <!-- 列表+分页查询 -->
  123. <el-table v-loading="loading" style="width:100%;margin:20px 0 0 6.5px;" :data="recordList" :header-cell-style='{"text-align":"center"}' :cell-style='{"text-align":"center"}'>
  124. <el-table-column label="ID">
  125. <template slot-scope="scope">
  126. <p>[[scope.row.id]]</p>
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="使用人">
  130. <template slot-scope="scope">
  131. <div class="marTop" v-if="isTypeNull(scope.row.yz_member)">
  132. <img v-if="scope.row.yz_member.has_one_member && scope.row.yz_member.has_one_member.avatar" width="30" height="30" :src="scope.row.yz_member.has_one_member.avatar">
  133. <p v-if="scope.row.yz_member.has_one_member && scope.row.yz_member.has_one_member.nickname">
  134. [[scope.row.yz_member.has_one_member.nickname]]</p>
  135. <p v-else class="not">暂定</p>
  136. </div>
  137. <div class="not" v-else>暂无</div>
  138. </template>
  139. </el-table-column>
  140. <el-table-column label="推荐人">
  141. <template slot-scope="scope">
  142. <div class="marTop" v-if="isTypeNull(scope.row.has_one_mc_member)">
  143. <img width="30" height="30" v-if="scope.row.has_one_mc_member.has_one_member && scope.row.has_one_mc_member.has_one_member.avatar" :src="scope.row.has_one_mc_member.has_one_member.avatar" alt="">
  144. <p v-if="scope.row.has_one_mc_member.has_one_member && scope.row.has_one_mc_member.has_one_member.nickname">
  145. [[scope.row.has_one_mc_member.has_one_member.nickname]]</p>
  146. <p v-else class="not">暂定</p>
  147. </div>
  148. <div class="not" v-else>暂无</div>
  149. </template>
  150. </el-table-column>
  151. <el-table-column label="邀请码">
  152. <template slot-scope="scope">
  153. <p>[[scope.row.invitation_code]]</p>
  154. </template>
  155. </el-table-column>
  156. <el-table-column label="使用时间">
  157. <template slot-scope="scope">
  158. <p>[[scope.row.created_at]]</p>
  159. </template>
  160. </el-table-column>
  161. </el-table>
  162. </div>
  163. <div v-if="recordList.length!==0" class="fixed total-floo">
  164. <div class="fixed_box">
  165. <el-pagination background style="text-align: right;" @current-change="handleCurrentChange" :current-page.sync="currentPage" :page-size="pagesize" layout="prev, pager, next, jumper" :total="total">
  166. </el-pagination>
  167. </div>
  168. </div>
  169. </div>
  170. </div>
  171. <script>
  172. const vm = new Vue({
  173. el: "#app",
  174. name: "invited",
  175. // 防止后端冲突,修改ma语法符号
  176. delimiters: ['[[', ']]'],
  177. data() {
  178. return {
  179. invite: {
  180. code: "",
  181. id: "",
  182. select_info: [],
  183. time: "1",
  184. date: "",
  185. start: "",
  186. end: "",
  187. times: [{
  188. value: '1',
  189. label: '搜索时间'
  190. }, {
  191. value: '0',
  192. label: '时间不限'
  193. }],
  194. pickerOptions: {
  195. shortcuts: [{
  196. text: '最近一周',
  197. onClick(picker) {
  198. const end = new Date();
  199. const start = new Date();
  200. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  201. picker.$emit('pick', [start, end]);
  202. }
  203. }, {
  204. text: '最近一个月',
  205. onClick(picker) {
  206. const end = new Date();
  207. const start = new Date();
  208. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  209. picker.$emit('pick', [start, end]);
  210. }
  211. }, {
  212. text: '最近三个月',
  213. onClick(picker) {
  214. const end = new Date();
  215. const start = new Date();
  216. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  217. picker.$emit('pick', [start, end]);
  218. }
  219. }]
  220. },
  221. },
  222. recordList: [],
  223. currentPage: 1, //当前的页码
  224. pagesize: 5, //每页显示的行数
  225. total: 0, //总数
  226. //记录请求
  227. isi: true,
  228. loading: true,
  229. inviteArr: []
  230. }
  231. },
  232. created() {
  233. //优化在不同设备固定定位挡住的现象设置父元素的内边距
  234. window.onload = function() {
  235. let all = document.querySelector(".all");
  236. let h = window.innerHeight * 0.03;
  237. all.style.paddingBottom = h + "px";
  238. }
  239. g = this;
  240. //请求当前列表数据
  241. if (this.isi) {
  242. this.isi = false
  243. this.invite.time = [];
  244. this.postInvited(1);
  245. }
  246. //全局监听searchBtnt enter事件
  247. document.onkeydown = (e) => {
  248. let key = window.event.keyCode;
  249. if (key == 13) {
  250. g.searchBtn();
  251. }
  252. }
  253. },
  254. updated() {
  255. // console.log(this.invite);
  256. },
  257. watch: {
  258. invite: {
  259. handler(newVal) {
  260. this.inviteArr["code"] = this.invite.code;
  261. this.inviteArr["mid"] = this.invite.id;
  262. this.inviteArr["searchtime"] = this.invite.time;
  263. this.inviteArr["times"] = [this.invite.start];
  264. this.inviteArr["times"].push(this.invite.end);
  265. },
  266. immediate: true,
  267. deep: true
  268. }
  269. },
  270. methods: {
  271. isTypeNull(str) {
  272. // 如果对象 或者为空则返回
  273. if (str !== null) {
  274. return true
  275. } else {
  276. return false;
  277. }
  278. },
  279. //页面切换的方式
  280. handleCurrentChange(page) {
  281. this.postInvited(page)
  282. },
  283. postInvited(page) {
  284. //邀请码记录列表
  285. this.$http.post("{!!yzWebFullUrl('member.member_invited.show')!!}", {
  286. page: page,
  287. search: {
  288. code: this.invite.code,
  289. mid: this.invite.id,
  290. // searchtime: this.invite.time,
  291. times: {
  292. start: parseInt(this.invite.start),
  293. end: parseInt(this.invite.end)
  294. }
  295. }
  296. }).then(res => {
  297. if (res.status === 200) {
  298. setTimeout(() => {
  299. this.loading = false;
  300. }, 100)
  301. let {
  302. data: list,
  303. current_page: page,
  304. per_page: per,
  305. total: total
  306. } = res.body.data.list;
  307. console.log(list);
  308. if (list !== null && list.length !== 0) {
  309. //列表数据
  310. this.recordList = list;
  311. } else {
  312. this.recordList = [];
  313. }
  314. //当前页码
  315. this.currentPage = page;
  316. //总数
  317. this.total = total;
  318. //一页显示几行数据
  319. this.pagesize = per;
  320. } else {
  321. this.$message.error("获取数据失败");
  322. }
  323. })
  324. },
  325. //点击搜索
  326. searchBtn() {
  327. if (!this.invite.date) {
  328. this.invite.date = [];
  329. }
  330. // console.log(this.invite.date[0]);
  331. // console.log(this.invite.date[1]);
  332. this.invite.start = this.invite.date[0] / 1000;
  333. this.invite.end = this.invite.date[1] / 1000;
  334. //请求搜索指定数据
  335. this.postInvited(this.currentPage);
  336. },
  337. //时间的转换
  338. timeDate(date) {
  339. let d = new Date(date);
  340. let resDate = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();;
  341. return resDate;
  342. }, //导出
  343. deriveEvent() {
  344. // console.log(this.inviteArr,4545465);
  345. // console.log(this.inviteArr.code,49999);
  346. console.log(this.inviteArr["times"][0], this.inviteArr["times"][1], 99999);
  347. let start = "";
  348. let end = "";
  349. if (this.inviteArr["times"][0] && this.inviteArr["times"][1]) {
  350. start = isNaN(this.inviteArr["times"][0]) ? "" : parseInt(this.inviteArr["times"][0]);
  351. end = isNaN(this.inviteArr["times"][1]) ? "" : parseInt(this.inviteArr["times"][1]);
  352. }
  353. console.log(start, end);
  354. let url = `{!! yzWebFullUrl('member.member_invited.export')!!}&search[code]=` +
  355. this.inviteArr.code + "&search[mid]=" + this.inviteArr.mid + "&search[times][start]=" + start + "&search[times][end]=" + end;
  356. console.log(url)
  357. window.location.href = url;
  358. },
  359. },
  360. })
  361. </script>@endsection