deal.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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 :dataList="courseList" :listType="2"></courseList>
  64. </div>
  65. <noData :list="courseList" />
  66. </scroller>
  67. <scroller
  68. ref="recordScroller"
  69. :on-infinite="getMoreList"
  70. noDataText="没有更多..."
  71. :list="recordList"
  72. v-show="active == 1"
  73. >
  74. <div class="dealRecordList" v-show="active == 1">
  75. <div
  76. class="recordLi"
  77. v-for="(item, index) in recordList"
  78. :key="index"
  79. >
  80. <div class="flex-name-num">
  81. <p>{{ item.subjectName }}</p>
  82. <span :style="{color:item.toUserId == target_user_info.id ?'#26A2FF':'#eb6f6f'}"
  83. >{{ item.toUserId == target_user_info.id ? "收到" : "卖出"
  84. }}{{ item.amount }}套</span
  85. >
  86. </div>
  87. <p>{{ item.content }}</p>
  88. <span>{{ item.createTime }}</span>
  89. </div>
  90. </div>
  91. <van-divider
  92. v-if="recordList.length != 0 && recordList.length == page1.total"
  93. style="line-height: .6rem;"
  94. >没有更多了...</van-divider
  95. >
  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. // 初始化
  151. init() {
  152. this.user_info = this.$route.query;
  153. this.getList();
  154. this.getRecordList();
  155. },
  156. // 初始化数据
  157. resetList() {
  158. this.active = 0;
  159. this.page.cur = 1;
  160. this.page.total = 0;
  161. this.page1.cur = 1;
  162. this.page1.total = 0;
  163. this.noDate = false;
  164. this.noDate1 = false;
  165. this.courseList = [];
  166. this.recordList = [];
  167. this.getList();
  168. this.getRecordList();
  169. },
  170. // 触底加载
  171. getMoreList(done) {
  172. if (this.active == 0) {
  173. if (!this.noDate) {
  174. setTimeout(() => {
  175. this.getList(done);
  176. }, 300);
  177. } else {
  178. this.$refs.courseScroller.finishInfinite(true);
  179. }
  180. } else {
  181. if (!this.noDate1) {
  182. setTimeout(() => {
  183. this.getRecordList(done);
  184. }, 300);
  185. } else {
  186. this.$refs.recordScroller.finishInfinite(true);
  187. }
  188. }
  189. },
  190. // 获取待确认的交易列表
  191. getList(done) {
  192. let data = {
  193. page: this.page.cur,
  194. pageSize: this.page.size,
  195. status: 1
  196. };
  197. getDealerRecord(this.$route.params.id, data).then(res => {
  198. res.list.forEach(item => {
  199. item.dealAmount = item.amount;
  200. item.subjectThumb = item.thumb;
  201. item.subjectPrice = item.price;
  202. delete item.amount;
  203. delete item.thumb;
  204. delete item.price;
  205. });
  206. this.courseList = this.courseList.concat(res.list);
  207. this.page.cur = res.current;
  208. this.page.total = res.total;
  209. if (res.pages == this.page.cur) {
  210. if (done) done(true);
  211. this.noDate = true;
  212. } else {
  213. if (done) done();
  214. this.page.cur++; //下拉一次页数+1
  215. this.noDate = false;
  216. }
  217. });
  218. },
  219. // 获取已交易的列表
  220. getRecordList(done) {
  221. let data = {
  222. page: this.page1.cur,
  223. pageSize: this.page1.size,
  224. status: 2
  225. };
  226. getDealerRecord(this.$route.params.id, data).then(res => {
  227. this.page1.cur = res.current;
  228. this.page1.total = res.total;
  229. this.recordList = this.recordList.concat(res.list);
  230. if (res.pages == this.page1.cur) {
  231. console.log("没有更多");
  232. if (done) done(true);
  233. this.noDate1 = true;
  234. } else {
  235. if (done) done();
  236. this.page1.cur++; //下拉一次页数+1
  237. this.noDate1 = false;
  238. }
  239. });
  240. },
  241. // 确认交易
  242. dealCourseNum() {
  243. this.$router.push(`/course/dealOrder/${this.$route.params.id}`);
  244. },
  245. // 标签切换
  246. activeChange(e) {
  247. this.active = e;
  248. },
  249. //导航左侧返回
  250. onClickLeft() {
  251. this.$router.go(-1);
  252. }
  253. }
  254. };
  255. </script>
  256. <style scoped lang="scss">
  257. * {
  258. margin: 0;
  259. padding: 0;
  260. }
  261. .deal-x {
  262. background-color: #efefef;
  263. .userInfo {
  264. padding: 0.24rem 0.32rem;
  265. .userImage {
  266. display: flex;
  267. align-items: center;
  268. flex: 1;
  269. .info {
  270. display: flex;
  271. flex-direction: column;
  272. justify-content: center;
  273. margin-left: 0.2rem;
  274. span {
  275. font-size: 0.32rem;
  276. font-weight: 600;
  277. color: #000;
  278. line-height: 2;
  279. display: block;
  280. }
  281. p {
  282. font-size: 0.22rem;
  283. color: #222;
  284. line-height: 1;
  285. display: block;
  286. }
  287. }
  288. }
  289. .user_leave {
  290. padding: 0.15rem 0.3rem;
  291. font-size: 0.26rem;
  292. font-weight: 550;
  293. color: #26A2FF;
  294. border: 1px solid #26A2FF;
  295. border-radius: 0.1rem;
  296. line-height: 1.5;
  297. margin-left: .2rem;
  298. }
  299. }
  300. .user_tabs {
  301. margin: 0 0.2rem;
  302. border-radius: 0.1rem;
  303. position: relative;
  304. overflow: hidden;
  305. &::after {
  306. content: "";
  307. width: 1px;
  308. height: 60%;
  309. position: absolute;
  310. left: 50%;
  311. top: 20%;
  312. background-color: #898989;
  313. }
  314. }
  315. .dealScroll {
  316. height: calc(100vh - 3.5rem) !important;
  317. padding: 0 0.2rem;
  318. position: relative;
  319. &::after {
  320. content: "";
  321. width: calc(100% - 0.2rem);
  322. height: 1px;
  323. position: absolute;
  324. top: 0;
  325. left: 0.1rem;
  326. background-color: #efefef;
  327. }
  328. .dealList {
  329. padding: 0.15rem 0.2rem 0;
  330. border-radius: 0.1rem;
  331. }
  332. .dealRecordList {
  333. padding: 0 0.2rem;
  334. border-radius: 0.1rem;
  335. margin-top: 0.1rem;
  336. .recordLi {
  337. background: #fff;
  338. padding: 0 0.2rem;
  339. overflow: hidden;
  340. &:not(:nth-last-child(1)) {
  341. border-bottom: 1px solid #efefef;
  342. }
  343. &:first-child {
  344. border-radius: 0.1rem 0.1rem 0 0;
  345. }
  346. &:last-child {
  347. border-radius: 0 0 0.1rem 0.1rem;
  348. }
  349. .flex-name-num {
  350. display: flex;
  351. justify-content: space-between;
  352. align-items: center;
  353. padding-top: 0.1rem;
  354. & > p {
  355. font-size: 0.32rem;
  356. color: #000;
  357. line-height: 1.5;
  358. }
  359. & > span {
  360. font-size: 0.28rem;
  361. color: #000;
  362. line-height: 2;
  363. margin-left: 0.1rem;
  364. }
  365. }
  366. & > p {
  367. font-size: 0.28rem;
  368. color: #666;
  369. line-height: 1;
  370. }
  371. & > span {
  372. font-size: 0.28rem;
  373. color: #666;
  374. line-height: 1;
  375. display: block;
  376. margin-top: 0.2rem;
  377. margin-bottom: 0.1rem;
  378. }
  379. }
  380. }
  381. }
  382. }
  383. </style>