index.vue 3.1 KB

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