user-manage.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <view class="user">
  3. <view class="search_box flexB">
  4. <view class="search_inp flexB">
  5. <text class="iconfont iconsearch"></text>
  6. <input placeholder="请输入订单号" placeholder-style="color:#fff;font-size:28rpx;"
  7. v-model="params.search_name" />
  8. <text class="iconfont icondelete" @click="clear()"></text>
  9. </view>
  10. <view class="search_btn" @click="params.page_index==1,getList()">查询</view>
  11. </view>
  12. <view class="block"></view>
  13. <view class="tabs flexA" v-if="!params.search_name">
  14. <view @click="dateTab('yesterday')" :class="params.cycle == 'yesterday' ? 'active_tab' : ''">昨日</view>
  15. <view @click="dateTab('today')" :class="params.cycle == 'today' ? 'active_tab' : ''">今日</view>
  16. <view @click="dateTab('week')" :class="params.cycle == 'week' ? 'active_tab' : ''">本周</view>
  17. <view @click="dateTab('month')" :class="params.cycle == 'month' ? 'active_tab' : ''">本月</view>
  18. <view @click="dateTab('all')" :class="params.cycle == 'all' ? 'active_tab' : ''">全部</view>
  19. </view>
  20. <view class="user_data" v-if="!params.search_name">
  21. <view class="flexA">
  22. <view class="data_item">
  23. <view>{{userData.total||0}}</view>
  24. <text>销量</text>
  25. </view>
  26. <view class="data_item">
  27. <view>¥{{userData.account||0}}</view>
  28. <text>销售额</text>
  29. </view>
  30. <view class="data_item">
  31. <view>{{ userData.count||0 }}</view>
  32. <text>已购客户</text>
  33. </view>
  34. </view>
  35. <view class="cap_chart">
  36. <area-chart :chartData="chartData" />
  37. </view>
  38. </view>
  39. <view class="block"></view>
  40. <view class="user_con">
  41. <view class="flexB user_title">
  42. <text>头像</text>
  43. <text>昵称</text>
  44. <text>购买量</text>
  45. <text>成交额</text>
  46. </view>
  47. <view class="user_list" v-for="(item,idx) in userList" :key="idx">
  48. <view class="flexA user_info">
  49. <view>
  50. <image :src="item.user.avatar" class="avatar" v-if="item.user"></image>
  51. </view>
  52. <view style="white-space: nowrap;" v-if="item.user">{{ item.user.nickname | getName(10) }}</view>
  53. <view style="font-weight: bold;">{{ item.total }}</view>
  54. <view v-if="item.account" style="font-weight: bold;">¥{{ parseInt(item.account) }}</view>
  55. </view>
  56. <view class="user_opear flexS">
  57. <view @click="skipOrder(item)">订单详情</view>
  58. <view @click="skipUser(item.user_id)">客户信息</view>
  59. </view>
  60. </view>
  61. <view class="noData" v-if="userList.length==0">
  62. <image src="/static/imgs/default/no_card.png" mode=""></image>
  63. <view>--暂无数据--</view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. import areaChart from '../../components/charts/area-chart.vue';
  70. import {
  71. getUserData,
  72. getUserList
  73. } from '@/apis/shop.js';
  74. export default {
  75. data() {
  76. return {
  77. userData: '', //用户数据信息
  78. userList: '', //用户列表
  79. searchName: '',
  80. params: {
  81. cycle: 'all',
  82. page_index: 1,
  83. page_size: 5,
  84. search_name: ''
  85. },
  86. chartData: {}, //曲线图数据
  87. totalPage: 0
  88. };
  89. },
  90. components: {
  91. areaChart
  92. },
  93. onShow() {
  94. this.getData();
  95. this.getList();
  96. },
  97. onReachBottom() {
  98. this.getMoreList();
  99. },
  100. methods: {
  101. //清空输入框
  102. clear() {
  103. this.params.search_name = '';
  104. this.getData();
  105. this.getList();
  106. },
  107. //切换销售数据中的
  108. dateTab(cycle) {
  109. this.params.cycle = cycle;
  110. this.params.page_index = 1;
  111. this.getData();
  112. this.getList();
  113. },
  114. //跳转到完善用户信息
  115. skipUser(user_id) {
  116. uni.navigateTo({
  117. url: '../../../pages/complete-info/complete-info?user_id=' + user_id
  118. });
  119. },
  120. /*跳转到用户订单*/
  121. skipOrder(item) {
  122. uni.navigateTo({
  123. url: `../../../pages/order-manage/order-manage?user_id=${item.user_id}&&nickname=${item.user.nickname}`
  124. });
  125. },
  126. //获取用户总数据及曲线图
  127. async getData() {
  128. // this.chartData = '';
  129. const res = await getUserData({
  130. cycle: this.params.cycle
  131. });
  132. try {
  133. const {
  134. code,
  135. data
  136. } = res;
  137. if (code === 200) {
  138. this.userData = data;
  139. let line = data.line;
  140. let x = [];
  141. let y = [];
  142. for (let k in line) {
  143. y.push(line[k])
  144. if (this.params.cycle != 'all') {
  145. let index = k.indexOf('\-');
  146. k = k.substring(index + 1, k.length);
  147. }
  148. x.push(k)
  149. }
  150. this.chartData = {
  151. categories: x,
  152. series: [{
  153. name: '数量',
  154. data: y
  155. }]
  156. };
  157. } else {
  158. uni.showModal({
  159. content: data || '获取数据失败',
  160. showCancel: false
  161. })
  162. }
  163. } catch (e) {
  164. uni.showModal({
  165. content: e || '获取数据失败',
  166. showCancel: false
  167. })
  168. }
  169. },
  170. //获取用户列表
  171. async getList(isMore) {
  172. uni.showLoading({
  173. title: '加载中...'
  174. })
  175. const res = await getUserList(this.params);
  176. try {
  177. const {
  178. code,
  179. data
  180. } = res;
  181. if (code === 200) {
  182. this.totalPage = Math.ceil(data.total / this.params.page_size)
  183. this.userList = isMore ? this.userList.concat(data.list) : data.list;
  184. } else {
  185. uni.showModal({
  186. content: data || '获取数据失败',
  187. showCancel: false
  188. })
  189. }
  190. uni.hideLoading()
  191. } catch (e) {
  192. uni.showModal({
  193. content: e || '获取数据失败',
  194. showCancel: false
  195. })
  196. uni.hideLoading()
  197. }
  198. },
  199. /*获取更多扫码用户*/
  200. getMoreList() {
  201. if (this.params.page_index >= this.totalPage) {
  202. uni.showToast({
  203. title: '没有更多啦~',
  204. icon: 'none'
  205. });
  206. return false;
  207. }
  208. this.params.page_index++;
  209. this.getList(true)
  210. }
  211. }
  212. };
  213. </script>
  214. <!-- <style>
  215. page {
  216. width: 100%;
  217. min-height: 100%;
  218. background: #F9F9FB;
  219. }
  220. </style> -->
  221. <style lang="scss">
  222. .cap_chart {
  223. height: 300px;
  224. margin-top: 30rpx;
  225. width: 100%;
  226. overflow: hidden;
  227. z-index: 99
  228. }
  229. .user {
  230. padding-bottom: 100rpx;
  231. .search_box {
  232. width: 690rpx;
  233. margin: 0 auto;
  234. height: 100rpx;
  235. padding: 5rpx 0;
  236. .search_inp {
  237. margin: 0 auto;
  238. border: 2rpx solid #ccc;
  239. height: 80rpx;
  240. padding: 0 20rpx;
  241. box-sizing: border-box;
  242. border-radius: 44rpx;
  243. input {
  244. width: 80%;
  245. height: 80rpx;
  246. line-height: 80rpx;
  247. }
  248. .iconfont {
  249. color: #999;
  250. font-size: 40rpx;
  251. }
  252. }
  253. }
  254. .tabs {
  255. padding: 0 30rpx;
  256. margin: 30rpx 0;
  257. box-sizing: border-box;
  258. .active_tab {
  259. background: linear-gradient(95deg, #ff232c 0%, #ff571b 100%);
  260. color: #fff;
  261. border: none;
  262. }
  263. view {
  264. width: 120rpx;
  265. text-align: center;
  266. height: 60rpx;
  267. line-height: 60rpx;
  268. border-radius: 32rpx;
  269. border: 2rpx solid #999999;
  270. color: #999;
  271. }
  272. }
  273. .user_data {
  274. padding: 15rpx 0;
  275. .data_item {
  276. text-align: center;
  277. view {
  278. font-size: 60rpx;
  279. font-weight: bold;
  280. margin-bottom: 20rpx;
  281. }
  282. text {
  283. font-size: 28rpx;
  284. color: #999;
  285. }
  286. }
  287. }
  288. .user_con {
  289. width: 100%;
  290. .user_title {
  291. width: 100%;
  292. height: 88rpx;
  293. border-bottom: 2rpx solid #eee;
  294. font-size: 32rpx;
  295. text {
  296. width: 25%;
  297. text-align: center;
  298. }
  299. }
  300. .user_list {
  301. .user_info {
  302. width: 100%;
  303. height: 100rpx;
  304. background: #fff;
  305. view {
  306. width: 25%;
  307. text-align: center;
  308. font-size: 32rpx;
  309. .avatar {
  310. width: 68rpx;
  311. height: 68rpx;
  312. border-radius: 50%;
  313. }
  314. }
  315. }
  316. .user_opear {
  317. width: 100%;
  318. height: 68rpx;
  319. background: #f8f8f8;
  320. view {
  321. width: 50%;
  322. height: 68rpx;
  323. line-height: 68rpx;
  324. text-align: center;
  325. color: $base-color;
  326. font-weight: bold;
  327. }
  328. }
  329. }
  330. }
  331. }
  332. </style>