sliderDialog.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <view class="">
  3. <!-- <uni-popup ref="sliderPopup" :animation="false" :is-mask-click="false"
  4. mask-background-color="rgba(255, 255, 255, 0.6);">
  5. <view class="slider-check-dialog">
  6. <view class="slider-check-content">
  7. <text>请通过滑块验证</text>
  8. <view id="yzm-slider"></view>
  9. <view @click="sliderClose">关闭</view>
  10. </view>
  11. </view>
  12. </uni-popup> -->
  13. <view style="margin-top: 200px;" id="yzm-slider"></view>
  14. <view style="margin-top: 100px;" @click="AWSC.emitData">关闭1111</view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. mounted() {
  20. },
  21. data() {
  22. return {
  23. sliderObj: {
  24. sessionId: '',
  25. sig: '',
  26. token: '',
  27. }
  28. }
  29. },
  30. methods: {
  31. receiveRenderData(data) {
  32. console.log("获得接受")
  33. console.log(data)
  34. this.$emit('emitFun', data)
  35. // this.$emit('success');
  36. // this.sliderClose()
  37. },
  38. sliderShow() {
  39. this.$refs.sliderPopup.open()
  40. },
  41. sliderClose() {
  42. this.$refs.sliderPopup.close()
  43. }
  44. }
  45. }
  46. </script>
  47. <script module="AWSC" lang="renderjs">
  48. export default {
  49. mounted() {
  50. const script = document.createElement('script');
  51. script.src = 'https://g.alicdn.com/AWSC/AWSC/awsc.js';
  52. document.body.appendChild(script);
  53. script.onload = () => {
  54. this.init()
  55. }
  56. },
  57. data() {
  58. return {
  59. sessionId: '',
  60. sig: '',
  61. token: '',
  62. }
  63. },
  64. methods: {
  65. init() {
  66. let that =this
  67. AWSC.use("nc", function(state, module) {
  68. nc = module.init({
  69. // 应用类型标识。它和使用场景标识(scene字段)一起决定了滑动验证的业务场景与后端对应使用的策略模型。您可以在阿里云验证码控制台的配置管理页签找到对应的appkey字段值,请务必正确填写。
  70. appkey: "FFFF0N00000000007EC0",
  71. //使用场景标识。它和应用类型标识(appkey字段)一起决定了滑动验证的业务场景与后端对应使用的策略模型。您可以在阿里云验证码控制台的配置管理页签找到对应的scene值,请务必正确填写。
  72. scene: "nc_message_h5",
  73. // 声明滑动验证需要渲染的目标ID。
  74. renderTo: "yzm-slider",
  75. //前端滑动验证通过时会触发该回调参数。您可以在该回调参数中将会话ID(sessionId)、签名串(sig)、请求唯一标识(token)字段记录下来,随业务请求一同发送至您的服务端调用验签。
  76. success: function(data) {
  77. window.console && console.log(data.sessionId, "111")
  78. window.console && console.log(data.sig, "222")
  79. window.console && console.log(data.token, "3333")
  80. that.getData(data)
  81. },
  82. // 滑动验证失败时触发该回调参数。
  83. fail: function(failCode) {
  84. console.log('失败:' + failCode)
  85. },
  86. // 验证码加载出现异常时触发该回调参数。
  87. error: function(errorCode) {
  88. console.log('异常:' + errorCode)
  89. }
  90. });
  91. })
  92. },
  93. getData(data){
  94. console.log(data)
  95. this.sessionId =data.sessionId
  96. this.sig =data.sig
  97. this.token =data.token
  98. },
  99. emitData(e, ownerInstance) {
  100. console.log(ownerInstance)
  101. console.log(this.sessionId)
  102. console.log(this)
  103. ownerInstance.callMethod('receiveRenderData', {
  104. sessionId: this.sessionId,
  105. sig: this.sig,
  106. token: this.token
  107. })
  108. }
  109. }
  110. }
  111. </script>