index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. <div
  6. class="toast-layout"
  7. :style="{background:isLoaing?'none':'rgba(0, 0, 0, 0.3)'}"
  8. :class="{'toast-active':isLoaing}"
  9. >
  10. <div class="loading">
  11. <svg viewBox="0 0 28 19">
  12. <path
  13. 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"
  14. ></path>
  15. </svg>
  16. </div>
  17. </div>
  18. <div
  19. class="toast-layout"
  20. :style="{background:isLoaing?'none':'rgba(0, 0, 0, 0.3)'}"
  21. :class="{'toast-active':visible}"
  22. >
  23. <div class="toast-con">
  24. <div class="detail">
  25. <div>
  26. <p class="main-msg" v-html="message"></p>
  27. <p class="sub-msg">{{submsg}}</p>
  28. </div>
  29. </div>
  30. <div class="bottom" v-if="toastType==='comfirm'">
  31. <span @click="visible=false" class="btn primary">{{lang==='en'?'Cancel':'取消'}}</span>
  32. <span class="b-line"></span>
  33. <span class="btn primary" @click="emitCallback">{{diycomfirm||comfirmtxt}}</span>
  34. </div>
  35. <div class="bottom mid-bottom" v-else>
  36. <span class="btn primary" @click="emitCallback">{{diycomfirm||comfirmtxt}}</span>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </template>
  42. <script>
  43. import binding from './binding'
  44. import addcart from './addcart'
  45. let types = {
  46. warn: '提示',
  47. error: '错误',
  48. success: '成功'
  49. }
  50. let typesEn = {
  51. warn: 'Message',
  52. error: 'Error',
  53. success: 'Success'
  54. }
  55. export default {
  56. components: {binding, addcart},
  57. data () {
  58. return {
  59. bindingType: 1,
  60. visible: false,
  61. bindingVisible: false,
  62. addcartVisible: false,
  63. addcartmsg: false,
  64. addcarbtnTxt: false,
  65. message: '',
  66. submsg: '',
  67. type: 'warn',
  68. toastType: 'show',
  69. callback: '',
  70. comfirmtxt: '确定',
  71. diycomfirm: '',
  72. isLoaing: false,
  73. lang: localStorage.getItem('language'),
  74. img: this.$cdn + 'images/icon/warn.png'
  75. }
  76. },
  77. computed: {
  78. typeTxt () {
  79. return this.lang === 'en' ? typesEn[this.type] : types[this.type]
  80. }
  81. },
  82. created () {},
  83. watch: {
  84. visible: function (newVal) {
  85. this.lang = localStorage.getItem('language')
  86. this.comfirmtxt = this.lang === 'en' ? 'OK' : '确定'
  87. }
  88. },
  89. mounted () {},
  90. methods: {
  91. handleAddCart (data) {
  92. this.addcartVisible = false
  93. data && this.callback()
  94. },
  95. emitCallback () {
  96. this.callback()
  97. this.visible = false
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. @import './style.scss';
  104. </style>