index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <view class="sales-warp">
  3. <view id="tjCons">
  4. <!--销售数据统计 -->
  5. <view class="content-data">
  6. <view class="date-type">
  7. <text v-for="(item, index) in tabNav" :key="index" :class="[index == navInd ? 'active_day' : '']" @click="seleteTime(index)">{{item.name}}</text>
  8. </view>
  9. <view class="total">
  10. <view class="item-box">
  11. <u-count-to v-if="navInd==0" :end-val="bizData&&bizData.sales&&(bizData.sales.dayTotalQty || bizData.sales.dayTotalQty==0) ? bizData.sales.dayTotalQty : 0" separator=","></u-count-to>
  12. <u-count-to v-if="navInd==1" :end-val="bizData&&bizData.sales&&(bizData.sales.weekSalesQty || bizData.sales.weekSalesQty==0) ? bizData.sales.weekSalesQty : 0" separator=","></u-count-to>
  13. <u-count-to v-if="navInd==2" :end-val="bizData&&bizData.sales&&(bizData.sales.monthSalesQty || bizData.sales.monthSalesQty==0) ? bizData.sales.monthSalesQty : 0" separator=","></u-count-to>
  14. <view>销售总单量(个)</view>
  15. </view>
  16. <view class="item-box">
  17. <u-count-to v-if="navInd==0" :end-val="bizData&&bizData.sales&&(bizData.sales.dayTotalAmount || bizData.sales.dayTotalAmount==0) ? bizData.sales.dayTotalAmount : 0" separator="," :decimals="2"></u-count-to>
  18. <u-count-to v-if="navInd==1" :end-val="bizData&&bizData.sales&&(bizData.sales.weekSalesAmount || bizData.sales.weekSalesAmount==0) ? bizData.sales.weekSalesAmount : 0" separator="," :decimals="2"></u-count-to>
  19. <u-count-to v-if="navInd==2" :end-val="bizData&&bizData.sales&&(bizData.sales.monthSalesAmount || bizData.sales.monthSalesAmount==0) ? bizData.sales.monthSalesAmount : 0" separator="," :decimals="2"></u-count-to>
  20. <view>销售总金额(¥)</view>
  21. </view>
  22. </view>
  23. </view>
  24. <!-- 产品报价及新增销售单 -->
  25. <view class="nav-cont flex align_center justify_between">
  26. <view class="nav-item" @click="toPage('/pages/sales/productPricing')">
  27. <u-image class="nav-pic" style="margin-top: 5upx;" :src="`../../static/${theme}/navIcon/price_icon.png`" width="60" height="60"></u-image>
  28. <text class="nav-txt" style="margin-top: 5upx;">产品报价</text>
  29. </view>
  30. <!-- <view class="nav-item" @click="toPage('/pages/sales/chooseCustomer')">
  31. <u-image class="nav-pic" :src="`../../static/${theme}/navIcon/sale_icon.png`" width="70" height="70"></u-image>
  32. <text class="nav-txt">新增销售单</text>
  33. </view> -->
  34. <view class="nav-item" @click="toPage('/pages/webviews/openview?title=产品查询&url=https://jgqp.51cjml.com/h5/#!/')">
  35. <u-image class="nav-pic" :src="`../../static/${theme}/navIcon/pfind.png`" width="64" height="64"></u-image>
  36. <text class="nav-txt">产品查询</text>
  37. </view>
  38. </view>
  39. <!-- 销售单 -->
  40. <view class="sales-list">
  41. <view class="title">
  42. <text class="title-name" @click="$refs.salesList.refash()">
  43. 销售单
  44. <u-icon name="reload" color="#2979ff" size="28"></u-icon>
  45. </text>
  46. <view class="title-all" @click="toPage('/pages/sales/list')">查看全部<u-icon name="arrow-right" color="rgb(144, 147, 153)" size="28"></u-icon></view>
  47. </view>
  48. </view>
  49. </view>
  50. <!-- 销售单列表 -->
  51. <listComponent ref="salesList" :height="listHeight" />
  52. </view>
  53. </template>
  54. <script>
  55. import ListComponent from './listComponent.vue'
  56. import { toThousands } from '@/libs/tools'
  57. import { bizData } from '@/api/sales'
  58. export default{
  59. components: { ListComponent },
  60. data(){
  61. return{
  62. tabNav: [
  63. { name: '今日', ind: 0 },
  64. { name: '本周', ind: 1 },
  65. { name: '本月', ind: 2 }
  66. ],
  67. navInd: 0,
  68. bizData: null, // 销售数据统计
  69. theme: '',
  70. listHeight: 400
  71. }
  72. },
  73. onReady() {
  74. const query = uni.createSelectorQuery().in(this);
  75. query.select('#tjCons').boundingClientRect(data => {
  76. this.listHeight = Math.floor(data.height + 18)
  77. }).exec();
  78. },
  79. onLoad() {
  80. const _this = this
  81. this.$nextTick(function(){
  82. // 监听整改完成后刷新事件
  83. uni.$on('refreshSalesHomeBL', function(data){
  84. _this.$refs.salesList.refash()
  85. })
  86. })
  87. const theme = getApp().globalData.theme
  88. this.theme = theme
  89. uni.setTabBarItem({
  90. "index": 0,
  91. "iconPath": "static/"+theme+"/tabbar/home.png",
  92. "selectedIconPath": "static/"+theme+"/tabbar/home-active.png",
  93. })
  94. uni.setTabBarItem({
  95. "index": 1,
  96. "iconPath": "static/"+theme+"/tabbar/stock.png",
  97. "selectedIconPath": "static/"+theme+"/tabbar/stock-active.png",
  98. })
  99. uni.setTabBarItem({
  100. "index": 2,
  101. "iconPath": "static/"+theme+"/tabbar/shelf.png",
  102. "selectedIconPath": "static/"+theme+"/tabbar/shelf-active.png",
  103. })
  104. uni.setTabBarItem({
  105. "index": 3,
  106. "iconPath": "static/"+theme+"/tabbar/user.png",
  107. "selectedIconPath": "static/"+theme+"/tabbar/user-active.png",
  108. })
  109. uni.setTabBarStyle({
  110. color: this.$config("topBarTitleColors"),
  111. selectedColor: this.$config("primaryColor"),
  112. borderStyle: 'white',
  113. complete: function(res){
  114. console.log(res)
  115. }
  116. })
  117. },
  118. onUnload() {
  119. uni.$off('refreshSalesHomeBL')
  120. },
  121. onShow() {
  122. this.navInd = 0
  123. this.getBizData()
  124. },
  125. methods:{
  126. seleteTime(val){
  127. this.navInd = val
  128. },
  129. toPage(url){
  130. uni.navigateTo({ url: url })
  131. },
  132. getBizData () {
  133. bizData({}).then(res => {
  134. if (res.status == 200) {
  135. this.bizData = res.data || null
  136. } else {
  137. this.bizData = null
  138. }
  139. uni.stopPullDownRefresh();
  140. })
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="scss">
  146. .sales-warp{
  147. width: 100%;
  148. padding: 20rpx 20upx;
  149. .color_6{
  150. color: #666;
  151. }
  152. .font_13{
  153. font-size: 26upx;
  154. }
  155. .content-data{
  156. background-color: #fff;
  157. padding: 20upx 20upx;
  158. border-radius: 20upx;
  159. box-shadow: 3upx 2upx 6upx #eee;
  160. margin-bottom: 20upx;
  161. .date-type{
  162. margin: 0 120upx 20upx;
  163. border-radius: 50upx;
  164. border: 1upx solid #eee;
  165. text{
  166. display: inline-block;
  167. padding: 10upx 0;
  168. width: 33%;
  169. text-align: center;
  170. }
  171. text:first-child{
  172. border-top-left-radius: 50upx;
  173. border-bottom-left-radius: 50upx;
  174. }
  175. text:last-child{
  176. border-top-right-radius: 50upx;
  177. border-bottom-right-radius: 50upx;
  178. }
  179. text:not(:last-child){
  180. border-right: 1upx solid #eee;
  181. }
  182. .active_day {
  183. background: rgb(0, 122, 255);
  184. color: #fff;
  185. }
  186. }
  187. .total{
  188. display: flex;
  189. .item-box{
  190. text-align: center;
  191. width: 50%;
  192. color:#999;
  193. }
  194. .item-box:first-child{
  195. border-right: 1px solid #e4e7ed;
  196. }
  197. }
  198. }
  199. .nav-cont{
  200. .nav-item{
  201. width: 49%;
  202. border-radius: 25upx;
  203. background-color: #ffffff;
  204. padding: 14upx 0;
  205. box-shadow: 3upx 2upx 6upx #eee;
  206. margin-bottom: 20upx;
  207. text-align: center;
  208. .nav-pic{
  209. margin: 0 auto;
  210. }
  211. .nav-txt{
  212. font-size: 28upx;
  213. color: #666666;
  214. }
  215. }
  216. }
  217. .sales-list{
  218. .title{
  219. margin-bottom: 14upx;
  220. display: flex;
  221. align-items: center;
  222. justify-content: space-between;
  223. .title-name{
  224. font-size: 32upx;
  225. color: #333;
  226. font-weight: 1000;
  227. }
  228. .title-all{
  229. color: rgb(144, 147, 153);
  230. }
  231. }
  232. }
  233. }
  234. </style>