index copy01.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <view class="activationcode">
  3. <!-- 头部 -->
  4. <view class="atco_header">
  5. <view class="r_flex_align">
  6. <view class="gs-logo-box r_flex_center">
  7. <image class="gs-logo" src="/static/background/gs-logo.png" style="width: 100%; height: 78%; background: #fff"></image>
  8. </view>
  9. <view class="r_margin_10"> 信飞通 </view>
  10. </view>
  11. <view class="">
  12. <text>扫码录入路由器</text>
  13. </view>
  14. </view>
  15. <i-dolphin :strokeWidth="1" class="settingt" theme="outline" size="100" fill="#fff" strokeLinejoin="bevel" strokeLinecap="square" />
  16. <!-- 表单 -->
  17. <view class="atco_content">
  18. <!-- HTML -->
  19. <view class="">
  20. {{ txmText }}
  21. </view>
  22. <!-- 激活按钮 -->
  23. <view @click="getCofig" class="actBottom" :class="[actTrueKey ? '' : 'act-true']">
  24. <text style="position: relative; z-index: 9">扫码</text>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import store from '@/store'
  31. import * as UserApi from '@/api/user'
  32. import * as CaptchaApi from '@/api/captcha'
  33. import * as Verify from '@/utils/verify'
  34. import * as AppApi from '@/api/app'
  35. import wx from 'weixin-js-sdk'
  36. import WXJsSDK from './WXSDK.js'
  37. export default {
  38. data() {
  39. return {
  40. actTrueKey: true,
  41. txmText: 'null',
  42. windowHeight: ''
  43. }
  44. },
  45. methods: {
  46. clickScanCode() {
  47. let url = window.location.href.split('#')[0]
  48. newApi.getSignature({url}).then((res) => {
  49. if (res.code == 0) {
  50. this.sdk.config({
  51. beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
  52. debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  53. appId: res.data.appId, // 必填,公众号的唯一标识
  54. timestamp: res.data.timestamp, // 必填,生成签名的时间戳
  55. nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
  56. signature: res.data.signature, // 必填,签名
  57. jsApiList: ['scanQRCode'] // 必填,需要使用的JS接口列表
  58. })
  59. this.sdk.ready(() => {
  60. // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
  61. this.sdk.checkJsApi({
  62. jsApiList: ['scanQRCode'],
  63. success: (res) => {
  64. console.log('jweixin.ready', res)
  65. if (res.checkResult.getLocation == false) {
  66. console.log('微信版本低')
  67. return
  68. }
  69. }
  70. })
  71. this.sdk.error((err) => {
  72. this.sdk.error('接口调取失败', err)
  73. })
  74. this.sdk.scanQRCode({
  75. desc: 'scanQRCode desc',
  76. needResult: 1, // 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果,
  77. scanType: ['qrCode'], // 可以指定扫二维码还是条形码(一维码),默认二者都有
  78. success: (r) => {
  79. window.location.href = r.resultStr
  80. },
  81. error: function (error) {
  82. if (error.errMsg.indexOf('function_not_exist') > 0) {
  83. alert('版本过低请升级')
  84. }
  85. }
  86. })
  87. })
  88. }
  89. })
  90. }
  91. },
  92. onReady() {
  93. // 获取屏幕高度
  94. uni.getSystemInfo({
  95. success: (res) => {
  96. this.windowHeight = res.windowHeight
  97. }
  98. })
  99. },
  100. /**
  101. * 生命周期函数--监听页面加载
  102. */
  103. onLoad: function () {
  104. this.wxCofig()
  105. },
  106. methods: {
  107. getCofig() {
  108. wx.scanQRCode({
  109. needResult: 0, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  110. scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
  111. success: function (res) {
  112. var result = res.resultStr // 当needResult 为 1 时,扫码返回的结果
  113. this.txmText = res
  114. }
  115. })
  116. },
  117. wxCofig() {
  118. WXJsSDK.init({
  119. APIs: ['scanQRCode']
  120. })
  121. },
  122. // 获取图形验证码
  123. getCaptcha() {
  124. const app = this
  125. CaptchaApi.image().then((result) => (app.captcha = result.data))
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. .activationcode {
  132. position: relative;
  133. background-color: #fff;
  134. height: 100vh;
  135. width: 100%;
  136. background: url('/static/background/zjx-bg.jpeg') #fff;
  137. background-size: 100%;
  138. background-repeat: no-repeat;
  139. background-position: top;
  140. overflow: hidden;
  141. font-size: 40rpx;
  142. background-image: linear-gradient(300deg, #b721ff 0%, #21d4fd 100%);
  143. }
  144. .atco_header {
  145. width: 100%;
  146. color: #fff;
  147. text-align: left;
  148. padding: 40rpx 80rpx;
  149. font-weight: 500;
  150. line-height: 70rpx;
  151. }
  152. .atco_content {
  153. position: relative;
  154. background: #fff;
  155. border-top-left-radius: 100rpx;
  156. border-top-right-radius: 100rpx;
  157. height: 100vh;
  158. padding: 80rpx 100rpx;
  159. font-size: 30rpx;
  160. overflow: hidden;
  161. background-image: linear-gradient(120deg, #fdfbfb 0%, #ebedee 100%);
  162. .atco_title {
  163. padding-left: 20rpx;
  164. color: #000;
  165. }
  166. }
  167. // 页面头部
  168. .header {
  169. margin-bottom: 50rpx;
  170. .title {
  171. color: #0081ff;
  172. font-size: 50rpx;
  173. font-weight: 900;
  174. }
  175. .sub-title {
  176. margin-top: 20rpx;
  177. color: #0080ffa9;
  178. font-size: 25rpx;
  179. }
  180. }
  181. .shiming {
  182. margin-top: 90rpx;
  183. }
  184. .settingt {
  185. position: absolute;
  186. right: 0rpx;
  187. top: 20rpx;
  188. color: #007aec5e;
  189. }
  190. // 输入框元素
  191. .form-item {
  192. position: relative;
  193. z-index: 9;
  194. display: flex;
  195. align-items: center;
  196. margin-bottom: 45rpx;
  197. margin-top: 15rpx;
  198. height: 86rpx;
  199. font-size: 28rpx;
  200. color: #333;
  201. border-radius: 10px;
  202. background: #fff;
  203. border-bottom: 2px solid #9399ff;
  204. border-right: 1px solid #9399ff;
  205. &--input {
  206. font-size: 28rpx;
  207. letter-spacing: 1rpx;
  208. flex: 1;
  209. height: 100%;
  210. color: #333;
  211. padding-left: 30rpx;
  212. }
  213. &--parts {
  214. display: flex;
  215. align-items: center;
  216. min-width: 100rpx;
  217. height: 100%;
  218. }
  219. // 图形验证码
  220. .captcha {
  221. height: 100%;
  222. .image {
  223. display: block;
  224. width: 192rpx;
  225. height: 100%;
  226. }
  227. }
  228. // 短信验证码
  229. .captcha-sms {
  230. font-size: 30rpx;
  231. line-height: 50rpx;
  232. padding-right: 40rpx;
  233. .activate {
  234. color: #0081ff;
  235. }
  236. .un-activate {
  237. color: #9e9e9e;
  238. }
  239. }
  240. }
  241. .actBottom {
  242. position: fixed;
  243. bottom: 100rpx;
  244. right: 0rpx;
  245. left: 0rpx;
  246. margin: 0 auto;
  247. font-size: 50rpx;
  248. color: #007aec;
  249. text-align: center;
  250. display: block;
  251. width: 200rpx;
  252. height: 200rpx;
  253. line-height: 200rpx;
  254. border-radius: 50%;
  255. background: linear-gradient(145deg, #c5f4ff, #a6cde6);
  256. box-shadow: 7px 7px 14px #007aecbd, -7px -7px 14px #a6cde686;
  257. border: 1px solid #fff;
  258. }
  259. .renlian {
  260. width: 100%;
  261. background: #6f77fe;
  262. color: #fff !important;
  263. text-align: center;
  264. justify-content: center;
  265. }
  266. .act-true {
  267. color: #333;
  268. background: linear-gradient(145deg, #dddddd, #bababa);
  269. box-shadow: 7px 7px 14px #7a7a7a, -7px -7px 14px #ffffff;
  270. }
  271. // 提交按钮
  272. .submit-button {
  273. width: 100%;
  274. height: 86rpx;
  275. margin-top: 70rpx;
  276. background: linear-gradient(to right, $main-bg, $main-bg2);
  277. color: $main-text;
  278. border-radius: 80rpx;
  279. box-shadow: 0px 10px 20px 0px rgba(0, 0, 0, 0.1);
  280. letter-spacing: 5rpx;
  281. display: flex;
  282. justify-content: center;
  283. align-items: center;
  284. background-image: linear-gradient(-20deg, #b721ff 0%, #21d4fd 100%);
  285. }
  286. </style>