index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div>
  3. <binding :btype="bindingType" :visible='bindingVisible' @closePoint="()=>{bindingVisible = false,emitCallback()}"/>
  4. <addcart :visible='addcartVisible' :img='img' :msg='addcartmsg' :txt='addcarbtnTxt' @closePoint="handleAddCart" />
  5. <cooperation :sceneNum="sceneNum" :visible='cooperationVisible' @closePoint="()=>{cooperationVisible = false,emitCallback()}"/>
  6. <div
  7. class="toast-layout"
  8. :style="{background:isLoaing?'none':'rgba(0, 0, 0, 0.3)'}"
  9. :class="{'toast-active':isLoaing}"
  10. >
  11. <div class="loading">
  12. <svg viewBox="0 0 28 19">
  13. <path
  14. d="M4 0l3 3C5.151 4.589 4.141 6.938 4 9c.141 2.994 1.18 5.374 3 7l-3 3c-2.512-2.51-4-5.919-4-10 0-3.134 1.446-6.499 4-9zm20 0c2.554 2.501 4 5.866 4 9 0 4.081-1.488 7.49-4 10l-3-3c1.82-1.626 2.859-4.006 3-7-.141-2.062-1.151-4.411-3-6l3-3z"
  15. ></path>
  16. </svg>
  17. </div>
  18. </div>
  19. <div
  20. class="toast-layout toast-show"
  21. :style="{background:isLoaing?'none':'rgba(0, 0, 0, 0.3)'}"
  22. :class="{'toast-active':visible}"
  23. v-if="toastType === 'show'"
  24. >
  25. <div class="toast-con">
  26. <div class="toast-icon">
  27. <h-icon :type="iconType" />
  28. </div>
  29. <div class="detail">
  30. <div>
  31. <p class="main-msg" v-html="message"></p>
  32. <p class="sub-msg">{{submsg}}</p>
  33. </div>
  34. </div>
  35. <div class="toast-show-bottom">
  36. <span class="" @click="emitCallback">{{diycomfirm||comfirmtxt}}</span>
  37. </div>
  38. </div>
  39. </div>
  40. <div
  41. class="toast-layout"
  42. :style="{background:isLoaing?'none':'rgba(0, 0, 0, 0.3)'}"
  43. :class="{'toast-active':visible}"
  44. v-else
  45. >
  46. <div class="toast-con">
  47. <div class="detail">
  48. <div>
  49. <p class="main-msg" v-html="message"></p>
  50. <p class="sub-msg">{{submsg}}</p>
  51. </div>
  52. </div>
  53. <div class="bottom" v-if="toastType==='comfirm'">
  54. <span @click="visible=false" class="btn primary">{{lang==='en'?'Cancel':'取消'}}</span>
  55. <span class="b-line"></span>
  56. <span class="btn primary" @click="emitCallback">{{diycomfirm||comfirmtxt}}</span>
  57. </div>
  58. <div class="bottom mid-bottom" v-else>
  59. <span class="btn primary" @click="emitCallback">{{diycomfirm||comfirmtxt}}</span>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. </template>
  65. <script>
  66. import binding from './binding'
  67. import addcart from './addcart'
  68. import cooperation from './cooperation'
  69. let types = {
  70. warn: '提示',
  71. error: '错误',
  72. success: '成功'
  73. }
  74. let iconType = {
  75. warn: 'tanhao',
  76. error: 'tanhao',
  77. success: 'duihao'
  78. }
  79. let typesEn = {
  80. warn: 'Message',
  81. error: 'Error',
  82. success: 'Success'
  83. }
  84. export default {
  85. components: {binding, addcart, cooperation},
  86. data () {
  87. return {
  88. bindingType: 1,
  89. sceneNum: '',
  90. visible: false,
  91. bindingVisible: false,
  92. addcartVisible: false,
  93. addcartmsg: false,
  94. cooperationVisible: false,
  95. addcarbtnTxt: false,
  96. message: '',
  97. submsg: '',
  98. type: 'warn',
  99. toastType: 'show',
  100. callback: '',
  101. comfirmtxt: '确定',
  102. diycomfirm: '',
  103. isLoaing: false,
  104. lang: localStorage.getItem('language'),
  105. img: this.$cdn + 'images/icon/warn.png'
  106. }
  107. },
  108. computed: {
  109. typeTxt () {
  110. return this.lang === 'en' ? typesEn[this.type] : types[this.type]
  111. },
  112. iconType () {
  113. return iconType[this.type] || 'tanhao'
  114. }
  115. },
  116. created () {},
  117. watch: {
  118. visible: function (newVal) {
  119. this.lang = localStorage.getItem('language')
  120. this.comfirmtxt = this.lang === 'en' ? 'OK' : '确定'
  121. }
  122. },
  123. mounted () {},
  124. methods: {
  125. handleAddCart (data) {
  126. this.addcartVisible = false
  127. data && this.callback()
  128. },
  129. emitCallback () {
  130. this.callback()
  131. this.visible = false
  132. }
  133. }
  134. }
  135. </script>
  136. <style lang="scss" scoped>
  137. @import './style.scss';
  138. </style>