t-i-navbar.vue 5.7 KB

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