merchantList.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <!-- 机器销售列表页 -->
  2. <template>
  3. <view class="">
  4. <view v-if="id!=1">
  5. <view v-if="equipmentList.length>0">
  6. <uni-collapse :accordion="true">
  7. <uni-list>
  8. <uni-list-item :title="$t('merchantList.total')" @click="openByAdmin(merchantList[0].name,merchantList[0].id)" />
  9. <view class="titlelist" v-for="equipment in equipmentList" :key="equipment.id">
  10. <uni-list-item :title="getEquipmentTitle(equipment)" @click="openByEquipment(merchantList[0].name,equipment.id)" />
  11. </view>
  12. </uni-list>
  13. </uni-collapse>
  14. </view>
  15. <view v-else style="text-align: center;">{{$t('merchantList.data')}}</view>
  16. </view>
  17. <view class="">
  18. <mix-tree :list="list" @treeItemClick="treeItemClick"></mix-tree>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import {
  24. mapState,
  25. mapActions,
  26. mapMutations
  27. } from 'vuex'
  28. import uniCollapse from '@/components/uni-collapse/uni-collapse.vue'
  29. import uniCollapseItem from '@/components/uni-collapse-item/uni-collapse-item.vue'
  30. import uniList from '@/components/uni-list/uni-list.vue'
  31. import uniListItem from '@/components/uni-list-item/uni-list-item.vue'
  32. import mixTree from '@/components/mix-tree/mix-tree'
  33. export default {
  34. components: {
  35. uniCollapse,
  36. uniCollapseItem,
  37. uniList,
  38. uniListItem,
  39. mixTree
  40. },
  41. data() {
  42. return {
  43. globalUser:{},
  44. merchantList: [{
  45. equipmentList: []
  46. }],
  47. equipmentList: [],
  48. extraIcon: {
  49. color: '#4cd964',
  50. size: '22',
  51. type: 'spinner'
  52. },
  53. id: null,
  54. pname:null,
  55. list: [],
  56. onReach:true,
  57. }
  58. },
  59. computed: {
  60. ...mapState(['loginUser']),
  61. },
  62. onReachBottom() {
  63. if(this.onReach) {
  64. this.globalUser.offset = this.globalUser.offset + this.globalUser.limit;
  65. this.getEquipmentListData();
  66. }
  67. },
  68. onShow() {
  69. uni.setNavigationBarTitle({title: this.$t('merchantList.title')});
  70. uni.setTabBarItem({ index: 1,text: this.$t('tabs.tab2')});
  71. this.globalUser = uni.getStorageSync("globalUser");
  72. this.id = this.globalUser.id;
  73. this.globalUser.offset = 1;
  74. this.globalUser.limit = 20;
  75. var token = uni.getStorageSync("token");
  76. if (token.length>1) {
  77. if(this.equipmentList.length === 0) {
  78. this.getEquipmentListData();
  79. }
  80. }else{
  81. uni.reLaunch({
  82. url: '../Login/Login',
  83. });
  84. }
  85. },
  86. onPullDownRefresh() {
  87. this.equipmentList = [];
  88. this.globalUser.offset = 1;
  89. this.globalUser.limit = 20;
  90. this.getEquipmentListData();
  91. },
  92. methods: {
  93. ...mapActions('chart', ['getEquipmentListByUser', 'getEquipmentListByProvince']),
  94. openByAdmin(pname, adminId) {
  95. uni.navigateTo({
  96. url: '../../packageB/pages/char/elseStatistics?adminId=' + adminId + '&pname=' + pname,
  97. });
  98. },
  99. openByEquipment(pname, equipmentId) {
  100. uni.navigateTo({
  101. url: '../../packageB/pages/char/elseStatistics?equipmentId=' + equipmentId + '&pname=' + pname,
  102. });
  103. },
  104. //点击最后一级时触发该事件
  105. treeItemClick(item) {
  106. let {
  107. id,
  108. name,
  109. parentId
  110. } = item;
  111. if(name=="总销售情况"){
  112. var token = uni.getStorageSync("token");
  113. uni.request({
  114. url: this.serverurl + '/TAdmin/findById',
  115. data: {
  116. "id": id,
  117. },
  118. method: "POST",
  119. header:{
  120. 'token':token
  121. },
  122. success: (res) => {
  123. this.pname = res.data.data.name;
  124. uni.navigateTo({
  125. url: '../../packageB/pages/char/elseStatistics?adminId=' + id + '&pname=' + this.pname,
  126. });
  127. }
  128. })
  129. }else{
  130. var token = uni.getStorageSync("token");
  131. uni.request({
  132. url: this.serverurl + '/TEquipment/findByEquipment',
  133. data: {
  134. "id": id,
  135. },
  136. method: "POST",
  137. header:{
  138. 'token':token
  139. },
  140. success: (res) => {
  141. this.pname = res.data.data.name;
  142. uni.navigateTo({
  143. url: '../../packageB/pages/char/elseStatistics?equipmentId=' + id + '&pname=' + this.pname,
  144. });
  145. }
  146. })
  147. }
  148. console.log(item)
  149. },
  150. getMerchantTitle(merchant) {
  151. return merchant.name ? merchant.name : merchant.username;
  152. },
  153. getEquipmentTitle(equipment) {
  154. return equipment.name ? equipment.name : equipment.clientId;
  155. },
  156. getEquipmentListData() {
  157. if(this.id==1){
  158. this.getEquipmentListByProvince(this.globalUser)
  159. .then(data => {
  160. this.list = data;
  161. }, _ => void uni.stopPullDownRefresh());
  162. }else{
  163. this.getEquipmentListByUser(this.globalUser)
  164. .then(data => {
  165. this.merchantList = data;
  166. if(data[0].equipmentList.length === 0) {
  167. this.onReach = false;
  168. }
  169. this.equipmentList.push(...data[0].equipmentList);
  170. var listName = data[0].equipmentList;
  171. var listId = data[0].id;
  172. if(listId!=null && listId!='1'){
  173. uni.setStorageSync("listName",listName);
  174. }
  175. uni.stopPullDownRefresh();
  176. }
  177. , _ => void uni.stopPullDownRefresh());
  178. }
  179. }
  180. }
  181. }
  182. </script>
  183. <style>
  184. .titlelist {
  185. color: #363D44;
  186. font-size: 16upx;
  187. font-family: "PingFang-SC-Medium";
  188. }
  189. </style>