t-i-navbar.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <view>
  3. <view class="content">
  4. <view class="status_bar">
  5. <!-- 这里是状态栏 -->
  6. </view>
  7. <view class="navbar">
  8. <view class="left" @click="switch_kuang()">
  9. <image v-if="mine_code == 'ningdongyunying'" src="./icon/ningdongyunying.png" mode=""></image>
  10. <image v-if="mine_code == 'zaoquan'" src="./icon/zaoquan.png" mode=""></image>
  11. <image v-if="mine_code == 'yangchangwan'" src="@/static/switch-kuang/yangchangwan.png" mode=""></image>
  12. <image v-if="mine_code == 'meihuajing'" src="@/static/switch-kuang/meihuajing.png" mode=""></image>
  13. <image v-if="mine_code == 'jinfeng'" src="@/static/switch-kuang/jinfeng.png" mode=""></image>
  14. <image v-if="mine_code == 'xixuan'" src="@/static/switch-kuang/xixuan.png" mode=""></image>
  15. <image v-if="mine_code == 'qingshuiying'" src="@/static/switch-kuang/qingshuiying.png" mode=""></image>
  16. <image v-if="mine_code == 'wuyegongsi'" src="@/static/switch-kuang/wuyegongsi.png" mode=""></image>
  17. <image v-if="mine_code == 'jinjiaqu'" src="@/static/switch-kuang/jinjiaqu.png" mode=""></image>
  18. <uni-icons type="arrowdown" color="#fff"></uni-icons>
  19. </view>
  20. <!-- <view class="left">
  21. <image v-if="mine_code == 'zaoquan'" src="./icon/zaoquan.png" mode=""></image>
  22. <image v-if="mine_code == 'yangchangwan'" src="@/static/switch-kuang/yangchangwan.png" mode=""></image>
  23. <image v-if="mine_code == 'meihuajing'" src="@/static/switch-kuang/meihuajing.png" mode=""></image>
  24. <image v-if="mine_code == 'jinfeng'" src="@/static/switch-kuang/jinfeng.png" mode=""></image>
  25. <image v-if="mine_code == 'xixuan'" src="@/static/switch-kuang/xixuan.png" mode=""></image>
  26. <image v-if="mine_code == 'qingshuiying'" src="@/static/switch-kuang/qingshuiying.png" mode=""></image>
  27. <image v-if="mine_code == 'wuyegongsi'" src="@/static/switch-kuang/wuyegongsi.png" mode=""></image>
  28. <image v-if="mine_code == 'jinjiaqu'" src="@/static/switch-kuang/jinjiaqu.png" mode=""></image>
  29. </view> -->
  30. <view class="search" v-if="mine_code != 'qingshuiying' && mine_code != 'wuyegongsi'">
  31. <view class="box">
  32. <view class="left" @click="go_search()">
  33. <view class="icon">
  34. <image src="./icon/search.png" mode=""></image>
  35. </view>
  36. <view class="text">搜索</view>
  37. </view>
  38. <view class="scan" @click="scan()">
  39. <image src="./icon/saoma.png" mode=""></image>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="right">
  44. <swiper class="box" autoplay circular vertical :interval="4000" :duration="1000">
  45. <swiper-item class="item">
  46. <view class="icon">
  47. <image src="./icon/day.png" mode=""></image>
  48. </view>
  49. <view class="num">{{temperature_curr}}</view>
  50. </swiper-item>
  51. <swiper-item class="item" @click="go_integral()">
  52. <view class="icon" style="margin-right: 4rpx;">
  53. 积分
  54. </view>
  55. <view class="num">{{total}} 分</view>
  56. </swiper-item>
  57. </swiper>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="status_bar"></view>
  62. <view style="height: 88rpx;"></view>
  63. </view>
  64. </template>
  65. <script>
  66. export default {
  67. name: "t-i-navbar",
  68. props: [
  69. "mine_code"
  70. ],
  71. data() {
  72. return {
  73. // 当前温度
  74. temperature_curr: "",
  75. // 总积分
  76. total: 0
  77. };
  78. },
  79. created() {
  80. // 当前温度
  81. uni.request({
  82. url: "http://api.k780.com/?app=weather.today&weaId=286&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json",
  83. method: "GET",
  84. success: (res) => {
  85. // console.log(res.data.result.temperature_curr)
  86. this.temperature_curr = res.data.result.temperature_curr
  87. }
  88. })
  89. // 登录签到
  90. this.add_staff_integral_increase()
  91. //查询员工积分
  92. this.get_staff_integral_query()
  93. },
  94. methods: {
  95. switch_kuang() {
  96. uni.navigateTo({
  97. url: "../../index/switch-kuang/switch-kuang"
  98. })
  99. },
  100. go_search() {
  101. uni.navigateTo({
  102. url: "../../index/search/search?mine_code=" + this.mine_code,
  103. animationType: "fade-in",
  104. animationDuration: 500
  105. })
  106. },
  107. scan() {
  108. // 只允许通过相机扫码
  109. uni.scanCode({
  110. onlyFromCamera: true,
  111. success: function(res) {
  112. // console.log('条码类型:' + res.scanType);
  113. // console.log('条码内容:' + res.result);
  114. let pageId = ""
  115. function GetQueryString(name) {
  116. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  117. var r = res.match(reg);
  118. if (r != null) return unescape(r[2]);
  119. return null;
  120. }
  121. console.log(GetQueryString("pageId"))
  122. if (GetQueryString("pageId")) {
  123. pageId = GetQueryString("pageId")
  124. } else {
  125. pageId = res.split('=')[1]
  126. }
  127. uni.navigateTo({
  128. url: "../../index/record/record?pageId=" + pageId + "&mine_code=" + this
  129. .mine_code,
  130. })
  131. }
  132. })
  133. },
  134. // 添加员工积分 登录签到
  135. add_staff_integral_increase() {
  136. this.$api.staff_integral_increase({
  137. staff_num: uni.getStorageSync('user').staff_num,
  138. integral_type: 1,
  139. integral_num: 1
  140. }).then((res) => {
  141. // console.log(res)
  142. if (res.data.content.is_exists == 0) {
  143. uni.showToast({
  144. icon: "none",
  145. title: "签到成功!"
  146. })
  147. }
  148. })
  149. },
  150. //查询员工积分
  151. get_staff_integral_query() {
  152. this.$api.staff_integral_query({
  153. staff_num: uni.getStorageSync('user').staff_num
  154. }).then((res) => {
  155. // console.log(res)
  156. this.total = res.data.content.data.integral_sum
  157. })
  158. },
  159. // 积分详情
  160. go_integral() {
  161. uni.navigateTo({
  162. url: "../../index/integral/integral?total=" + this.total
  163. })
  164. }
  165. }
  166. }
  167. </script>
  168. <style lang="scss">
  169. .content {
  170. position: fixed;
  171. top: 0;
  172. left: 0;
  173. z-index: 999;
  174. width: 750rpx;
  175. background-image: url(./icon/bg_img.jpg);
  176. background-size: 750rpx 334rpx;
  177. background-repeat: no-repeat;
  178. }
  179. .navbar {
  180. box-sizing: border-box;
  181. padding: 10rpx 25rpx;
  182. display: flex;
  183. align-items: center;
  184. justify-content: space-between;
  185. height: 88rpx;
  186. .left {
  187. display: flex;
  188. align-items: center;
  189. width: 170rpx;
  190. image {
  191. width: 165rpx;
  192. height: 48rpx;
  193. margin-right: 10rpx;
  194. }
  195. }
  196. .search {
  197. width: 370rpx;
  198. .box {
  199. display: flex;
  200. justify-content: space-between;
  201. align-items: center;
  202. height: 68rpx;
  203. background-color: rgba(255, 255, 255, .4);
  204. border-radius: 50rpx;
  205. box-sizing: border-box;
  206. padding: 0 20rpx;
  207. .left {
  208. display: flex;
  209. height: 68rpx;
  210. width: 300rpx;
  211. .icon {
  212. image {
  213. width: 21rpx;
  214. height: 21rpx;
  215. }
  216. }
  217. .text {
  218. color: #FFFFFF;
  219. font-size: 24rpx;
  220. }
  221. }
  222. .scan {
  223. width: 68rpx;
  224. text-align: right;
  225. line-height: 68rpx;
  226. image {
  227. width: 27rpx;
  228. height: 25rpx;
  229. }
  230. }
  231. }
  232. }
  233. .right {
  234. white-space: nowrap;
  235. color: #FFFFFF;
  236. font-size: 24rpx;
  237. width: 124rpx;
  238. margin-left: 20rpx;
  239. border-left: 2rpx solid #FFFFFF;
  240. box-sizing: border-box;
  241. padding-left: 20rpx;
  242. height: 40rpx;
  243. .box {
  244. width: 124rpx;
  245. height: 40rpx;
  246. .item {
  247. display: flex;
  248. align-items: center;
  249. .icon {
  250. margin-right: 10rpx;
  251. image {
  252. width: 40rpx;
  253. height: 40rpx;
  254. }
  255. }
  256. .num {
  257. color: #FFFFFF;
  258. font-size: 24rpx;
  259. }
  260. }
  261. }
  262. }
  263. }
  264. </style>