t-i-navbar.vue 7.9 KB

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