deal.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <template>
  2. <div class="deal-x">
  3. <van-nav-bar
  4. :title="title"
  5. left-text="返回"
  6. left-arrow
  7. @click-left="onClickLeft"
  8. ></van-nav-bar>
  9. <div class="userInfo">
  10. <van-row
  11. type="flex"
  12. class="imageName"
  13. justify="space-between"
  14. align="center"
  15. >
  16. <div class="userImage">
  17. <userImage
  18. class="about-me__avatar"
  19. :img_url="user_info.imgUrl"
  20. :user_name="user_info.name"
  21. width="1.12rem"
  22. height="1.12rem"
  23. ></userImage>
  24. <div class="info">
  25. <span
  26. >{{ user_info.name
  27. }}<van-icon
  28. name="notes-o"
  29. color="#E1B98B"
  30. style="margin-left: .1rem;"
  31. /></span>
  32. <p v-if="user_info.mobile != ''">手机:{{ user_info.mobile }}</p>
  33. </div>
  34. </div>
  35. <div class="user_leave" @click="dealCourseNum">
  36. <span>交易课程名额</span>
  37. </div>
  38. </van-row>
  39. </div>
  40. <div class="user_tabs">
  41. <van-tabs
  42. v-model="active"
  43. @click="activeChange"
  44. animated
  45. title-active-color="#26A2FF"
  46. >
  47. <van-tab
  48. v-for="(item, index) in activeList"
  49. :key="index"
  50. :title="item"
  51. ></van-tab>
  52. </van-tabs>
  53. </div>
  54. <div class="dealScroll">
  55. <scroller
  56. ref="courseScroller"
  57. :on-infinite="getMoreList"
  58. :list="courseList"
  59. noDataText="没有更多..."
  60. v-show="active == 0"
  61. >
  62. <div class="dealList">
  63. <courseList
  64. :dataList="courseList"
  65. :listType="2"
  66. @dealComfirm="dealComfirm"
  67. ></courseList>
  68. </div>
  69. <noData :list="courseList" />
  70. </scroller>
  71. <scroller
  72. ref="recordScroller"
  73. :on-infinite="getMoreList"
  74. noDataText="没有更多..."
  75. :list="recordList"
  76. v-show="active == 1"
  77. >
  78. <div class="dealRecordList" v-show="active == 1">
  79. <div
  80. class="recordLi"
  81. v-for="(item, index) in recordList"
  82. :key="index"
  83. >
  84. <div class="flex-name-num">
  85. <p>{{ item.subjectName }}</p>
  86. <span
  87. >{{ item.toUserId == target_user_info.id ? "收到" : "卖出"
  88. }}{{ item.amount }}</span
  89. >
  90. </div>
  91. <p>{{ item.content }}</p>
  92. <span>{{ item.createTime }}</span>
  93. </div>
  94. </div>
  95. <van-divider v-if="recordList.length != 0 && recordList.length == page1.total" style="line-height: .6rem;">没有更多了...</van-divider>
  96. <noData :list="recordList" />
  97. </scroller>
  98. </div>
  99. </div>
  100. </template>
  101. <script>
  102. import Vue from "vue";
  103. import { Tab, Tabs } from "vant";
  104. import courseList from "../components/courseList";
  105. import { getDealerRecord } from "../api";
  106. Vue.use(Tab);
  107. Vue.use(Tabs);
  108. export default {
  109. name: "deal",
  110. components: { courseList },
  111. data() {
  112. return {
  113. title: "交易",
  114. activeList: ["待确认的交易", "已交易的记录"],
  115. active: 0,
  116. noDate: false,
  117. noDate1: false,
  118. page: {
  119. cur: 1,
  120. size: 10,
  121. total: 0
  122. },
  123. page1: {
  124. cur: 1,
  125. size: 15,
  126. total: 0
  127. },
  128. user_info: {
  129. imgUrl: "",
  130. id: "wx15451154555",
  131. name: "新人",
  132. mobile: "15270803986"
  133. },
  134. target_user_info: JSON.parse(localStorage.getItem("wx_user_info")),
  135. courseList: [],
  136. recordList: []
  137. };
  138. },
  139. watch: {
  140. $route(to) {
  141. if (to.path.includes("/courseDeal/")) {
  142. this.resetList();
  143. }
  144. }
  145. },
  146. created() {
  147. this.init();
  148. },
  149. methods: {
  150. init() {
  151. this.user_info = this.$route.query;
  152. this.getList();
  153. this.getRecordList();
  154. },
  155. resetList() {
  156. this.active = 0;
  157. this.page.cur = 1;
  158. this.page.total = 0;
  159. this.page1.cur = 1;
  160. this.page1.total = 0;
  161. this.noDate = false;
  162. this.noDate1 = false;
  163. this.courseList = [];
  164. this.recordList = [];
  165. this.getList();
  166. this.getRecordList();
  167. },
  168. getMoreList(done) {
  169. if (this.active == 0) {
  170. if (!this.noDate) {
  171. setTimeout(() => {
  172. this.getList(done);
  173. }, 300);
  174. } else {
  175. this.$refs.courseScroller.finishInfinite(true);
  176. }
  177. } else {
  178. if (!this.noDate1) {
  179. setTimeout(() => {
  180. this.getRecordList(done);
  181. }, 300);
  182. } else {
  183. this.$refs.recordScroller.finishInfinite(true);
  184. }
  185. }
  186. },
  187. getList(done) {
  188. let data = {
  189. page: this.page.cur,
  190. pageSize: this.page.size,
  191. status: 1
  192. };
  193. getDealerRecord(this.$route.params.id, data).then(res => {
  194. res.list.forEach(item => {
  195. item.dealAmount = item.amount;
  196. item.subjectThumb = item.thumb;
  197. item.subjectPrice = item.price;
  198. delete item.amount;
  199. delete item.thumb;
  200. delete item.price;
  201. });
  202. this.courseList = this.courseList.concat(res.list);
  203. this.page.cur = res.current;
  204. this.page.total = res.total;
  205. if (this.courseList.length >= this.page.total) {
  206. if (done) done(true);
  207. this.noDate = true;
  208. } else {
  209. if (done) done();
  210. this.page.cur++; //下拉一次页数+1
  211. this.noDate = false;
  212. }
  213. });
  214. },
  215. getRecordList(done) {
  216. let data = {
  217. page: this.page1.cur,
  218. pageSize: this.page1.size,
  219. status: -1
  220. };
  221. getDealerRecord(this.$route.params.id, data).then(res => {
  222. this.page1.cur = res.current;
  223. this.page1.total = res.total;
  224. this.recordList = this.recordList.concat(res.list);
  225. if (this.recordList.length >= this.page1.total) {
  226. console.log("没有更多")
  227. if (done) done(true);
  228. this.noDate1 = true;
  229. } else {
  230. if (done) done();
  231. this.page1.cur++; //下拉一次页数+1
  232. this.noDate1 = false;
  233. }
  234. });
  235. },
  236. dealCourseNum() {
  237. this.$router.push(`/course/dealOrder/${this.$route.params.id}`);
  238. },
  239. dealComfirm(res) {
  240. },
  241. activeChange(e) {
  242. this.active = e;
  243. // this.page.cur = 1;
  244. // this.page1.cur = 1;
  245. },
  246. toUrl(url, id) {
  247. this.$router.push({
  248. path: url,
  249. params: id
  250. });
  251. },
  252. //导航左侧返回
  253. onClickLeft() {
  254. this.$router.go(-1);
  255. }
  256. }
  257. };
  258. </script>
  259. <style scoped lang="scss">
  260. * {
  261. margin: 0;
  262. padding: 0;
  263. }
  264. .deal-x {
  265. background-color: #efefef;
  266. .userInfo {
  267. padding: 0.24rem 0.32rem;
  268. .userImage {
  269. display: flex;
  270. align-items: center;
  271. .info {
  272. display: flex;
  273. flex-direction: column;
  274. justify-content: center;
  275. margin-left: 0.2rem;
  276. span {
  277. font-size: 0.32rem;
  278. font-weight: 600;
  279. color: #000;
  280. line-height: 2;
  281. display: block;
  282. }
  283. p {
  284. font-size: 0.22rem;
  285. color: #222;
  286. line-height: 1;
  287. display: block;
  288. }
  289. }
  290. }
  291. .user_leave {
  292. padding: 0.15rem 0.3rem;
  293. font-size: 0.26rem;
  294. font-weight: 550;
  295. color: #898989;
  296. border: 1px solid #c9c3c0;
  297. border-radius: 0.1rem;
  298. line-height: 1.5;
  299. }
  300. }
  301. .user_tabs {
  302. margin: 0 0.2rem;
  303. border-radius: 0.1rem;
  304. position: relative;
  305. overflow: hidden;
  306. &::after {
  307. content: "";
  308. width: 1px;
  309. height: 60%;
  310. position: absolute;
  311. left: 50%;
  312. top: 20%;
  313. background-color: #898989;
  314. }
  315. }
  316. .dealScroll {
  317. height: calc(100vh - 3.5rem) !important;
  318. padding: 0 0.2rem;
  319. position: relative;
  320. &::after {
  321. content: "";
  322. width: calc(100% - 0.2rem);
  323. height: 1px;
  324. position: absolute;
  325. top: 0;
  326. left: 0.1rem;
  327. background-color: #efefef;
  328. }
  329. .dealList {
  330. padding: 0.15rem 0.2rem 0;
  331. border-radius: 0.1rem;
  332. }
  333. .dealRecordList {
  334. padding: 0 0.2rem;
  335. border-radius: 0.1rem;
  336. margin-top: 0.1rem;
  337. .recordLi {
  338. background: #fff;
  339. padding: 0 0.2rem;
  340. &:not(:nth-last-child(1)) {
  341. border-bottom: 1px solid #efefef;
  342. }
  343. &:first-child{
  344. border-radius: .1rem .1rem 0 0;
  345. }
  346. &:last-child{
  347. border-radius: 0 0 .1rem .1rem;
  348. }
  349. .flex-name-num {
  350. display: flex;
  351. justify-content: space-between;
  352. align-items: center;
  353. & > p {
  354. font-size: 0.32rem;
  355. color: #000;
  356. line-height: 2;
  357. }
  358. & > span {
  359. font-size: 0.32rem;
  360. color: #000;
  361. line-height: 2;
  362. }
  363. }
  364. & > p {
  365. font-size: 0.28rem;
  366. color: #666;
  367. line-height: 2;
  368. }
  369. & > span {
  370. font-size: 0.28rem;
  371. color: #666;
  372. line-height: 2;
  373. }
  374. }
  375. }
  376. }
  377. }
  378. </style>