index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <input type="text" v-model="searchInfo.goods" @input="toInput" placeholder="搜索商品">
  5. </view>
  6. <view class="two">
  7. <tabs :tabs="tabs" @tabsChange="tabsChange">
  8. <view class="tabsList">
  9. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  10. <view class="list-scroll-view">
  11. <view class="list" v-for="(item,index) in list" :key="index" @tap="toInfo(item)">
  12. <view class="list_1">
  13. <text>
  14. <text class="iconfont icon-yonghu"></text>
  15. {{item.name}}
  16. </text>
  17. <text class="status">{{item.zhStatus}}</text>
  18. </view>
  19. <view class="list_2">
  20. <view class="other">
  21. <text>联系电话:</text>
  22. <text>{{item.tel||'暂无'}}</text>
  23. </view>
  24. </view>
  25. <view class="bottom" v-if="item.status=='0'">
  26. <button size="mini" type="default" @tap.stop="toExam(item,'0')">审核通过</button>
  27. <button size="mini" type="warn" @tap.stop="toExam(item,'1')">审核拒绝</button>
  28. </view>
  29. </view>
  30. <view class="is_bottom" v-if="is_bottom">
  31. <text>{{config.bottom_title}}</text>
  32. </view>
  33. </view>
  34. </scroll-view>
  35. </view>
  36. </tabs>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import tabs from '../../components/tabs/index.vue';
  42. export default {
  43. components: {
  44. tabs
  45. },
  46. data() {
  47. return {
  48. // 系统设置
  49. config: {},
  50. user: {},
  51. status: '',
  52. searchInfo: {},
  53. tabs: {
  54. active: '0',
  55. menu: []
  56. },
  57. list: [],
  58. total: 0,
  59. skip: 0,
  60. limit: 6,
  61. page: 0,
  62. // 数据是否触底
  63. is_bottom: false,
  64. scrollTop: 0,
  65. // 字典表
  66. statusList: [],
  67. }
  68. },
  69. onLoad: function(e) {
  70. const that = this;
  71. that.$set(that, `status`, e.status || '0');
  72. that.$set(that.tabs, `active`, e.status || '0');
  73. that.searchConfig();
  74. },
  75. onShow: async function(e) {
  76. const that = this;
  77. await that.searchOther();
  78. that.searchToken();
  79. },
  80. onPullDownRefresh: async function() {
  81. const that = this;
  82. that.clearPage();
  83. await that.search();
  84. uni.stopPullDownRefresh();
  85. },
  86. methods: {
  87. searchConfig() {
  88. const that = this;
  89. try {
  90. const res = uni.getStorageSync('config');
  91. if (res) that.$set(that, `config`, res);
  92. } catch (e) {
  93. uni.showToast({
  94. title: err.errmsg,
  95. icon: 'error',
  96. duration: 2000
  97. });
  98. }
  99. },
  100. searchToken() {
  101. const that = this;
  102. try {
  103. const res = uni.getStorageSync('token');
  104. if (res) {
  105. that.$set(that, `user`, res);
  106. that.search();
  107. }
  108. } catch (e) {
  109. uni.showToast({
  110. title: err.errmsg,
  111. icon: 'error',
  112. duration: 2000
  113. });
  114. }
  115. },
  116. async search() {
  117. const that = this;
  118. let user = that.user;
  119. let status = that.status;
  120. let info = {
  121. skip: that.skip,
  122. limit: that.limit,
  123. street: user.street,
  124. status: status,
  125. }
  126. let res;
  127. res = await that.$api(`/User/queryInfo`, 'GET', {
  128. ...info,
  129. ...that.searchInfo
  130. });
  131. if (res.errcode == '0') {
  132. let list = [...that.list, ...res.data];
  133. for (let val of list) {
  134. val.zhStatus = that.searchStatus(val.status)
  135. }
  136. that.$set(that, `list`, list);
  137. that.$set(that, `total`, res.total)
  138. } else {
  139. uni.showToast({
  140. title: res.errmsg,
  141. icon: 'none'
  142. })
  143. }
  144. },
  145. // 查询状态
  146. searchStatus(e) {
  147. const that = this;
  148. let data = that.statusList.find((i) => i.value == e);
  149. if (data) return data.label
  150. else return '暂无'
  151. },
  152. // 确认发货
  153. async toExam(item, type) {
  154. const that = this;
  155. let user = that.user;
  156. let obj = {}
  157. if (type == '0') obj.status == '1'
  158. else obj.status == '2'
  159. uni.showModal({
  160. title: '提示',
  161. content: '是否要确认审核?',
  162. success: async function(res) {
  163. if (res.confirm) {
  164. const res = await that.$api(`/User/${item._id}`, 'POST', obj);
  165. if (res.errcode == '0') {
  166. uni.showToast({
  167. title: '维护信息成功',
  168. icon: 'none'
  169. })
  170. that.clearPage()
  171. that.search()
  172. } else {
  173. uni.showToast({
  174. title: res.errmsg,
  175. icon: 'none'
  176. })
  177. }
  178. }
  179. }
  180. });
  181. },
  182. // 查看详情
  183. toInfo(item) {
  184. console.log(item);
  185. },
  186. // 分页
  187. toPage(e) {
  188. const that = this;
  189. let list = that.list;
  190. let limit = that.limit;
  191. if (that.total > list.length) {
  192. uni.showLoading({
  193. title: '加载中',
  194. mask: true
  195. })
  196. let page = that.page + 1;
  197. that.$set(that, `page`, page)
  198. let skip = page * limit;
  199. that.$set(that, `skip`, skip)
  200. that.search();
  201. uni.hideLoading();
  202. } else that.$set(that, `is_bottom`, true)
  203. },
  204. // 触底
  205. toScroll(e) {
  206. const that = this;
  207. let up = that.scrollTop;
  208. that.$set(that, `scrollTop`, e.detail.scrollTop);
  209. let num = Math.sign(up - e.detail.scrollTop);
  210. if (num == 1) that.$set(that, `is_bottom`, false);
  211. },
  212. // 输入框
  213. toInput(e) {
  214. const that = this;
  215. if (that.searchInfo.goods) that.$set(that.searchInfo, `goods`, e.detail.value)
  216. else that.$set(that, `searchInfo`, {})
  217. that.clearPage();
  218. that.search();
  219. },
  220. // 查询其他信息
  221. async searchOther() {
  222. const that = this;
  223. let res;
  224. // 查询状态
  225. res = await that.$api(`/DictData`, 'GET', {
  226. type: 'status'
  227. })
  228. if (res.errcode == '0') {
  229. that.$set(that, `statusList`, res.data);
  230. var menu = res.data.map((item) => {
  231. return {
  232. title: item.label,
  233. active: item.value
  234. }
  235. })
  236. that.$set(that.tabs, `menu`, menu)
  237. }
  238. },
  239. // 选择选项卡
  240. tabsChange(e) {
  241. const that = this;
  242. that.$set(that.tabs, `active`, e.active)
  243. that.$set(that, `status`, e.active);
  244. that.clearPage();
  245. that.search()
  246. },
  247. // 清空列表
  248. clearPage() {
  249. const that = this;
  250. that.$set(that, `list`, [])
  251. that.$set(that, `skip`, 0)
  252. that.$set(that, `limit`, 6)
  253. that.$set(that, `page`, 0)
  254. }
  255. }
  256. }
  257. </script>
  258. <style lang="scss">
  259. .content {
  260. display: flex;
  261. flex-direction: column;
  262. width: 100vw;
  263. height: 100vh;
  264. .one {
  265. padding: 2vw;
  266. input {
  267. padding: 2vw;
  268. background-color: var(--f1Color);
  269. font-size: var(--font14Size);
  270. border-radius: 5px;
  271. }
  272. }
  273. .two {
  274. position: relative;
  275. flex-grow: 1;
  276. background-color: var(--f9Color);
  277. .tabsList {
  278. position: relative;
  279. width: 100vw;
  280. height: 82vh;
  281. .list {
  282. background-color: #fff;
  283. border: 1px solid var(--f5Color);
  284. padding: 2vw;
  285. margin: 0 2vw 2vw 2vw;
  286. border-radius: 5px;
  287. .list_1 {
  288. display: flex;
  289. justify-content: space-between;
  290. padding: 2vw 0;
  291. font-size: var(--font14Size);
  292. .status {
  293. color: var(--fF0Color);
  294. }
  295. }
  296. .list_2 {
  297. .other {
  298. font-size: var(--font14Size);
  299. text:last-child {
  300. color: var(--f85Color);
  301. }
  302. }
  303. }
  304. .bottom {
  305. text-align: center;
  306. padding: 1vw 0;
  307. button {
  308. margin: 0 5px 0 0;
  309. }
  310. }
  311. }
  312. }
  313. }
  314. }
  315. .scroll-view {
  316. position: absolute;
  317. top: 0;
  318. left: 0;
  319. right: 0;
  320. bottom: 0;
  321. .list-scroll-view {
  322. display: flex;
  323. flex-direction: column;
  324. }
  325. }
  326. .is_bottom {
  327. text-align: center;
  328. text {
  329. padding: 2vw 0;
  330. display: inline-block;
  331. color: var(--f85Color);
  332. font-size: var(--font14Size);
  333. }
  334. }
  335. </style>