t-i-navbar-2.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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-2",
  68. props: [
  69. "mine_code",
  70. "navbar_bg_color"
  71. ],
  72. data() {
  73. return {
  74. // 当前温度
  75. temperature_curr: "",
  76. // 总积分
  77. total: 0
  78. };
  79. },
  80. created() {
  81. // 当前温度
  82. uni.request({
  83. url: "http://api.k780.com/?app=weather.today&weaId=286&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json",
  84. method: "GET",
  85. success: (res) => {
  86. // console.log(res.data.result.temperature_curr)
  87. this.temperature_curr = res.data.result.temperature_curr
  88. }
  89. })
  90. // 登录签到
  91. this.add_staff_integral_increase()
  92. //查询员工积分
  93. this.get_staff_integral_query()
  94. },
  95. methods: {
  96. switch_kuang() {
  97. uni.navigateTo({
  98. url: "../../index/switch-kuang/switch-kuang"
  99. })
  100. },
  101. go_search() {
  102. uni.navigateTo({
  103. url: "../../index/search/search?mine_code=" + this.mine_code,
  104. animationType: "fade-in",
  105. animationDuration: 500
  106. })
  107. },
  108. scan() {
  109. // 只允许通过相机扫码
  110. uni.scanCode({
  111. onlyFromCamera: true,
  112. success: function(res) {
  113. // console.log('条码类型:' + res.scanType);
  114. // console.log('条码内容:' + res.result);
  115. let pageId = ""
  116. function GetQueryString(name) {
  117. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  118. var r = res.match(reg);
  119. if (r != null) return unescape(r[2]);
  120. return null;
  121. }
  122. console.log(GetQueryString("pageId"))
  123. if (GetQueryString("pageId")) {
  124. pageId = GetQueryString("pageId")
  125. } else {
  126. pageId = res.split('=')[1]
  127. }
  128. uni.navigateTo({
  129. url: "../../index/record/record?pageId=" + pageId + "&mine_code=" + this
  130. .mine_code,
  131. })
  132. }
  133. })
  134. },
  135. // 添加员工积分 登录签到
  136. add_staff_integral_increase() {
  137. this.$api.staff_integral_increase({
  138. staff_num: uni.getStorageSync('user').staff_num,
  139. integral_type: 1,
  140. integral_num: 1
  141. }).then((res) => {
  142. // console.log(res)
  143. if (res.data.content.is_exists == 0) {
  144. uni.showToast({
  145. icon: "none",
  146. title: "签到成功!"
  147. })
  148. }
  149. })
  150. },
  151. //查询员工积分
  152. get_staff_integral_query() {
  153. this.$api.staff_integral_query({
  154. staff_num: uni.getStorageSync('user').staff_num
  155. }).then((res) => {
  156. // console.log(res)
  157. this.total = res.data.content.data.integral_sum
  158. })
  159. },
  160. // 积分详情
  161. go_integral() {
  162. uni.navigateTo({
  163. url: "../../index/integral/integral?total=" + this.total
  164. })
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="scss">
  170. .content {
  171. position: fixed;
  172. top: 0;
  173. left: 0;
  174. z-index: 999;
  175. width: 750rpx;
  176. background-image: url(./icon/bg_img.jpg);
  177. background-size: 750rpx 334rpx;
  178. background-repeat: no-repeat;
  179. }
  180. .navbar {
  181. box-sizing: border-box;
  182. padding: 10rpx 25rpx;
  183. display: flex;
  184. align-items: center;
  185. justify-content: space-between;
  186. height: 88rpx;
  187. .left {
  188. display: flex;
  189. align-items: center;
  190. width: 170rpx;
  191. image {
  192. width: 165rpx;
  193. height: 48rpx;
  194. margin-right: 10rpx;
  195. }
  196. }
  197. .search {
  198. width: 370rpx;
  199. .box {
  200. display: flex;
  201. justify-content: space-between;
  202. align-items: center;
  203. height: 68rpx;
  204. background-color: rgba(255, 255, 255, .4);
  205. border-radius: 50rpx;
  206. box-sizing: border-box;
  207. padding: 0 20rpx;
  208. .left {
  209. display: flex;
  210. height: 68rpx;
  211. width: 300rpx;
  212. .icon {
  213. image {
  214. width: 21rpx;
  215. height: 21rpx;
  216. }
  217. }
  218. .text {
  219. color: #FFFFFF;
  220. font-size: 24rpx;
  221. }
  222. }
  223. .scan {
  224. width: 68rpx;
  225. text-align: right;
  226. line-height: 68rpx;
  227. image {
  228. width: 27rpx;
  229. height: 25rpx;
  230. }
  231. }
  232. }
  233. }
  234. .right {
  235. white-space: nowrap;
  236. color: #FFFFFF;
  237. font-size: 24rpx;
  238. width: 124rpx;
  239. margin-left: 20rpx;
  240. border-left: 2rpx solid #FFFFFF;
  241. box-sizing: border-box;
  242. padding-left: 20rpx;
  243. height: 40rpx;
  244. .box {
  245. width: 124rpx;
  246. height: 40rpx;
  247. .item {
  248. display: flex;
  249. align-items: center;
  250. .icon {
  251. margin-right: 10rpx;
  252. image {
  253. width: 40rpx;
  254. height: 40rpx;
  255. }
  256. }
  257. .num {
  258. color: #FFFFFF;
  259. font-size: 24rpx;
  260. }
  261. }
  262. }
  263. }
  264. }
  265. </style>