t-i-navbar.vue 8.4 KB

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