merchantList.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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.globalUser.offset = 1;
  88. this.globalUser.limit = 20;
  89. this.getEquipmentListData();
  90. },
  91. methods: {
  92. ...mapActions('chart', ['getEquipmentListByUser', 'getEquipmentListByProvince']),
  93. openByAdmin(pname, adminId) {
  94. uni.navigateTo({
  95. url: '../../packageB/pages/char/elseStatistics?adminId=' + adminId + '&pname=' + pname,
  96. });
  97. },
  98. openByEquipment(pname, equipmentId) {
  99. uni.navigateTo({
  100. url: '../../packageB/pages/char/elseStatistics?equipmentId=' + equipmentId + '&pname=' + pname,
  101. });
  102. },
  103. //点击最后一级时触发该事件
  104. treeItemClick(item) {
  105. let {
  106. id,
  107. name,
  108. parentId
  109. } = item;
  110. if(name=="总销售情况"){
  111. var token = uni.getStorageSync("token");
  112. uni.request({
  113. url: this.serverurl + '/TAdmin/findById',
  114. data: {
  115. "id": id,
  116. },
  117. method: "POST",
  118. header:{
  119. 'token':token
  120. },
  121. success: (res) => {
  122. this.pname = res.data.data.name;
  123. uni.navigateTo({
  124. url: '../../packageB/pages/char/elseStatistics?adminId=' + id + '&pname=' + this.pname,
  125. });
  126. }
  127. })
  128. }else{
  129. var token = uni.getStorageSync("token");
  130. uni.request({
  131. url: this.serverurl + '/TEquipment/findByEquipment',
  132. data: {
  133. "id": id,
  134. },
  135. method: "POST",
  136. header:{
  137. 'token':token
  138. },
  139. success: (res) => {
  140. this.pname = res.data.data.name;
  141. uni.navigateTo({
  142. url: '../../packageB/pages/char/elseStatistics?equipmentId=' + id + '&pname=' + this.pname,
  143. });
  144. }
  145. })
  146. }
  147. console.log(item)
  148. },
  149. getMerchantTitle(merchant) {
  150. return merchant.name ? merchant.name : merchant.username;
  151. },
  152. getEquipmentTitle(equipment) {
  153. return equipment.name ? equipment.name : equipment.clientId;
  154. },
  155. getEquipmentListData() {
  156. if(this.id==1){
  157. this.getEquipmentListByProvince(this.globalUser)
  158. .then(data => {
  159. this.list = data;
  160. }, _ => void uni.stopPullDownRefresh());
  161. }else{
  162. this.getEquipmentListByUser(this.globalUser)
  163. .then(data => {
  164. this.merchantList = data;
  165. if(data[0].equipmentList.length === 0) {
  166. this.onReach = false;
  167. }
  168. this.equipmentList.push(...data[0].equipmentList);
  169. var listName = data[0].equipmentList;
  170. var listId = data[0].id;
  171. if(listId!=null && listId!='1'){
  172. uni.setStorageSync("listName",listName);
  173. }
  174. uni.stopPullDownRefresh();
  175. }
  176. , _ => void uni.stopPullDownRefresh());
  177. }
  178. }
  179. }
  180. }
  181. </script>
  182. <style>
  183. .titlelist {
  184. color: #363D44;
  185. font-size: 16upx;
  186. font-family: "PingFang-SC-Medium";
  187. }
  188. </style>