index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <view class="work-container">
  3. <!-- 轮播图 -->
  4. <uni-swiper-dot class="uni-swiper-dot-box" :info="data" :current="current" field="content">
  5. <swiper class="swiper-box" :current="swiperDotIndex" @change="changeSwiper">
  6. <swiper-item v-for="(item, index) in data" :key="index">
  7. <view class="swiper-item" @click="clickBannerItem(item)">
  8. <image :src="item.image" mode="aspectFill" :draggable="false" />
  9. </view>
  10. </swiper-item>
  11. </swiper>
  12. </uni-swiper-dot>
  13. <!-- 宫格组件 -->
  14. <uni-section title="工作台" type="line"></uni-section>
  15. <view class="grid-body">
  16. <uni-grid :column="3" :showBorder="false" >
  17. <uni-grid-item v-if="hasRole(['admin'])">
  18. <view class="grid-item-box" @click="goPage('user')">
  19. <u--image :showLoading="true" src="/static/images/icons/user.png" width="50rpx" height="50rpx" ></u--image>
  20. <text class="text">客户列表</text>
  21. </view>
  22. </uni-grid-item>
  23. <uni-grid-item v-if="hasRole(['companymgr'])">
  24. <view class="grid-item-box" @click="goPage('device')">
  25. <u--image :showLoading="true" src="/static/images/icons/device.png" width="50rpx" height="50rpx" ></u--image>
  26. <text class="text">设备列表</text>
  27. </view>
  28. </uni-grid-item>
  29. <uni-grid-item>
  30. <view class="grid-item-box" @click="goPage('wifi')">
  31. <u--image :showLoading="true" src="/static/images/icons/wifi.png" width="50rpx" height="50rpx" ></u--image>
  32. <text class="text">设备配网</text>
  33. </view>
  34. </uni-grid-item>
  35. <uni-grid-item v-if="hasRole(['admin'])">
  36. <view class="grid-item-box" @click="goPage('scan')">
  37. <u--image :showLoading="true" src="/static/images/icons/code.png" width="50rpx" height="50rpx" ></u--image>
  38. <text class="text">绑码激活</text>
  39. </view>
  40. </uni-grid-item>
  41. <uni-grid-item v-if="hasRole(['companymgr'])">
  42. <view class="grid-item-box" @click="scanCode()">
  43. <u--image :showLoading="true" src="/static/images/icons/scan.png" width="50rpx" height="50rpx" ></u--image>
  44. <text class="text">用户绑定</text>
  45. </view>
  46. </uni-grid-item>
  47. <uni-grid-item>
  48. <view class="grid-item-box" @click="watchDevice()">
  49. <u--image :showLoading="true" src="/static/images/icons/scan.png" width="50rpx" height="50rpx" ></u--image>
  50. <text class="text">查看设备</text>
  51. </view>
  52. </uni-grid-item>
  53. <uni-grid-item v-if="hasRole(['companymgr'])">
  54. <view class="grid-item-box" @click="goPage('alert')">
  55. <u--image :showLoading="true" src="/static/images/icons/alert.png" width="50rpx" height="50rpx" ></u--image>
  56. <text class="text">设备告警</text>
  57. </view>
  58. </uni-grid-item>
  59. <uni-grid-item v-if="hasRole(['companymgr'])">
  60. <view class="grid-item-box" @click="goPage('error')">
  61. <u--image :showLoading="true" src="/static/images/icons/error.png" width="50rpx" height="50rpx" ></u--image>
  62. <text class="text">异常列表</text>
  63. </view>
  64. </uni-grid-item>
  65. <uni-grid-item v-if="hasRole(['admin'])">
  66. <view class="grid-item-box" @click="scanCode()">
  67. <u--image :showLoading="true" src="/static/images/icons/scan.png" width="50rpx" height="50rpx" ></u--image>
  68. <text class="text">注销设备</text>
  69. </view>
  70. </uni-grid-item>
  71. </uni-grid>
  72. <u-modal :show="show" title="绑定设备" :showCancelButton="true" @confirm="bingDevice" >
  73. <view class="slot-content">
  74. <view>设备名称:{{ scanDevice.deviceName }}</view>
  75. <view>产品名称:{{ scanDevice.productName }}</view>
  76. <view>设备编号:{{ scanDevice.serialNumber }}</view>
  77. <view>激活日期:{{ scanDevice.activeTime }}</view>
  78. </view>
  79. </u-modal>
  80. </view>
  81. </view>
  82. </template>
  83. <script>
  84. import authObj from '@/plugins/auth.js';
  85. import {getDevcieByQrcode,bingDeviceDept} from '@/api/device/device';
  86. import UImage from "../../uni_modules/uview-ui/components/u--image/u--image";
  87. export default {
  88. components: {UImage},
  89. data() {
  90. return {
  91. current: 0,
  92. swiperDotIndex: 0,
  93. show:false,
  94. scanDevice:{},
  95. data: [{
  96. image: '/static/images/banner/banner01.jpg'
  97. },
  98. // {
  99. // image: '/static/images/banner/banner02.jpg'
  100. // },
  101. // {
  102. // image: '/static/images/banner/banner03.jpg'
  103. // }
  104. ]
  105. }
  106. },
  107. methods: {
  108. bingDevice(){
  109. this.show = false;
  110. bingDeviceDept(this.scanDevice).then(res=>{
  111. if(res.code == 200){
  112. this.$modal.showToast('绑定成功')
  113. }else{
  114. this.$modal.showToast(res.msg);
  115. }
  116. })
  117. },
  118. cancel(){
  119. this.scanDevice = {};
  120. this.show = false;
  121. },
  122. clickBannerItem(item) {
  123. console.log();
  124. },
  125. hasRole(role){
  126. return authObj.authRoleAdmin(role);
  127. },
  128. changeSwiper(e) {
  129. this.current = e.detail.current
  130. },
  131. changeGrid(e) {
  132. this.$modal.showToast('模块建设中~')
  133. },
  134. watchDevice(){
  135. let self = this;
  136. uni.scanCode({
  137. success: function (res) {
  138. console.log('条码内容:' + res.result);
  139. getDevcieByQrcode(res.result).then(res=>{
  140. let device = res.data;
  141. if(device != null){
  142. uni.navigateTo({
  143. url: '/pages/device/detail?id='+device.deviceId
  144. });
  145. }else{
  146. self.$modal.showToast('设备不存在或无权限')
  147. }
  148. });
  149. }
  150. });
  151. },
  152. scanCode(){
  153. let self = this;
  154. uni.scanCode({
  155. success: function (res) {
  156. console.log('条码内容:' + res.result);
  157. getDevcieByQrcode(res.result).then(res=>{
  158. let device = res.data;
  159. if(!device){
  160. self.$modal.showToast('未查到设备信息')
  161. }else{
  162. if(device.deptId != null){
  163. self.$modal.showToast('该设备已经绑定了用户')
  164. }else{
  165. self.scanDevice = device;
  166. self.show = true;
  167. }
  168. }
  169. });
  170. }
  171. });
  172. },
  173. goPage(path){
  174. if('device' == path){
  175. uni.navigateTo({
  176. url: '/pages/device/index'
  177. });
  178. }
  179. if('wifi' == path){
  180. uni.navigateTo({
  181. url: '/pages/wifi/index'
  182. });
  183. }
  184. if('scan' == path){
  185. uni.navigateTo({
  186. url: '/pages/device/scan'
  187. });
  188. }
  189. if('user' == path){
  190. uni.navigateTo({
  191. url: '/pages/user/index'
  192. });
  193. }
  194. if('alert' == path){
  195. uni.navigateTo({
  196. url: '/pages/device/alert'
  197. });
  198. }
  199. if('error' == path){
  200. uni.navigateTo({
  201. url: '/pages/device/error'
  202. });
  203. }
  204. }
  205. }
  206. }
  207. </script>
  208. <style lang="scss">
  209. /* #ifndef APP-NVUE */
  210. page {
  211. display: flex;
  212. flex-direction: column;
  213. box-sizing: border-box;
  214. background-color: #fff;
  215. min-height: 100%;
  216. height: auto;
  217. }
  218. view {
  219. font-size: 14px;
  220. line-height: inherit;
  221. }
  222. /* #endif */
  223. .text {
  224. text-align: center;
  225. font-size: 26rpx;
  226. margin-top: 10rpx;
  227. }
  228. .grid-item-box {
  229. flex: 1;
  230. /* #ifndef APP-NVUE */
  231. display: flex;
  232. /* #endif */
  233. flex-direction: column;
  234. align-items: center;
  235. justify-content: center;
  236. padding: 15px 0;
  237. }
  238. .uni-margin-wrap {
  239. width: 690rpx;
  240. width: 100%;
  241. ;
  242. }
  243. .swiper {
  244. height: 300rpx;
  245. }
  246. .swiper-box {
  247. height: 150px;
  248. }
  249. .swiper-item {
  250. /* #ifndef APP-NVUE */
  251. display: flex;
  252. /* #endif */
  253. flex-direction: column;
  254. justify-content: center;
  255. align-items: center;
  256. color: #fff;
  257. height: 300rpx;
  258. line-height: 300rpx;
  259. }
  260. @media screen and (min-width: 500px) {
  261. .uni-swiper-dot-box {
  262. width: 400px;
  263. /* #ifndef APP-NVUE */
  264. margin: 0 auto;
  265. /* #endif */
  266. margin-top: 8px;
  267. }
  268. .image {
  269. width: 100%;
  270. }
  271. }
  272. </style>