t-i-navbar.vue 5.8 KB

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