t-i-navbar.vue 6.1 KB

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