index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <div class="information-layout">
  3. <div class="top-con">
  4. <img :src="`${$cdn}images/info-bg.png`" alt="">
  5. <div class="tc">
  6. <div>
  7. <p>{{content.content||'尚未开通任何会员'}}</p>
  8. <!-- <p>{{addstar(info.userName)}}</p> -->
  9. </div>
  10. <div class="btn" @click="$router.push({name:'purchase'})">立即购买</div>
  11. </div>
  12. </div>
  13. <div class="user-con">
  14. <div class="user-top">
  15. <div class="user-img" :style="{backgroundImage:`url(${info.head||`${$cdn}images/head-default.png`})`}">
  16. </div>
  17. <div class="user-upload">
  18. <p>上传头像</p>
  19. <div type="button" class="ant-btn">
  20. <input class="el-upload" ref="uploadInput" name="file" type="file" @change="update">
  21. <span>选择文件</span>
  22. </div>
  23. <p>允许的文件类型为JPG 或 PNG。</p>
  24. </div>
  25. </div>
  26. </div>
  27. <div class="address-con">
  28. <p class="sub-title">
  29. <span>我的收货地址</span>
  30. </p>
  31. <div class="address-show" v-if="isShowAddress">
  32. <template v-if="address.shipName">
  33. <div class="add-info">
  34. <div class="show-name">
  35. <span>{{address.shipName}}</span>
  36. <span>{{address.shipMobile}}</span>
  37. </div>
  38. <div class="show-address">
  39. {{`${address.shipAreaPath}${address.shipAddress}`}}
  40. </div>
  41. </div>
  42. <div class="add-edit" @click="isShowAddress=false">
  43. <img :src="`${$cdn}images/icon/edit.png`" alt="">
  44. </div>
  45. </template>
  46. <template v-else>
  47. <div class="add-info">暂无地址信息</div>
  48. <div class="add-edit" @click="isShowAddress=false">
  49. <img :src="`${$cdn}images/icon/edit.png`" alt="">
  50. </div>
  51. </template>
  52. </div>
  53. <citySelect class="address-scon" :address='address' :token="token" @closeSelect="data=>{isShowAddress=data}" v-else/>
  54. </div>
  55. <div class="address-con">
  56. <p class="sub-title">我的发票抬头</p>
  57. <div class="invoice-show" v-if="isShowInvoice">
  58. <template v-if="invoice2.title||invoice3.title">
  59. <div class="add-info">
  60. <div class="show-name">
  61. <span>{{invoice2.title||invoice3.title}}</span>
  62. </div>
  63. <div class="show-address">
  64. {{invoice2.code}}
  65. </div>
  66. </div>
  67. <div class="add-edit" @click="isShowInvoice=false">
  68. <img :src="`${$cdn}images/icon/edit.png`" alt="">
  69. </div>
  70. </template>
  71. <template v-else>
  72. <div class="add-info">暂无发票信息</div>
  73. <div class="add-edit" @click="isShowInvoice=false">
  74. <img :src="`${$cdn}images/icon/edit.png`" alt="">
  75. </div>
  76. </template>
  77. </div>
  78. <invoices :invoice='editInvoice2' :invoicet="editInvoice3" :token="token" @closeInvoice="data=>{isShowInvoice=data}" v-else />
  79. </div>
  80. </div>
  81. </template>
  82. <script>
  83. import { mapState } from 'vuex'
  84. import citySelect from '@/components/citySelect'
  85. import invoices from '@/components/invoices'
  86. var cloneObj = function (obj) {
  87. var newObj = {}
  88. if (obj instanceof Array) {
  89. newObj = []
  90. }
  91. for (var key in obj) {
  92. var val = obj[key] || ''
  93. newObj[key] = typeof val === 'object' ? cloneObj(val) : val
  94. }
  95. return newObj
  96. }
  97. export default {
  98. components: {
  99. citySelect,
  100. invoices
  101. },
  102. computed: {
  103. ...mapState({
  104. info: state => state.user.info,
  105. token: state => state.user.token,
  106. invoice2: state => {
  107. let type = Object.prototype.toString.call(state.user.invoice2)
  108. if (type === '[object Object]') {
  109. return state.user.invoice2
  110. }
  111. let condition = state.user.invoice2 && state.user.invoice2 !== 'null' && type !== '[object Array]'
  112. return (condition ? JSON.parse(state.user.invoice2) : {})
  113. },
  114. editInvoice2: state => {
  115. let type = Object.prototype.toString.call(state.user.invoice2)
  116. if (type === '[object Object]') {
  117. return state.user.invoice2
  118. }
  119. let condition = state.user.invoice2 && state.user.invoice2 !== 'null' && type !== '[object Array]'
  120. return cloneObj(condition ? JSON.parse(state.user.invoice2) : {})
  121. },
  122. invoice3: state => {
  123. let type = Object.prototype.toString.call(state.user.invoice3)
  124. if (type === '[object Object]') {
  125. return state.user.invoice3
  126. }
  127. let condition = state.user.invoice3 && state.user.invoice3 !== 'null' && type !== '[object Array]'
  128. return (condition ? JSON.parse(state.user.invoice3) : {})
  129. },
  130. editInvoice3: state => {
  131. let type = Object.prototype.toString.call(state.user.invoice3)
  132. if (type === '[object Object]') {
  133. return state.user.invoice3
  134. }
  135. let condition = state.user.invoice3 && state.user.invoice3 !== 'null' && type !== '[object Array]'
  136. return cloneObj(condition ? JSON.parse(state.user.invoice3) : {})
  137. },
  138. address: state => state.user.address || {},
  139. editAdd: state => cloneObj(state.user.address) || {}
  140. })
  141. },
  142. data () {
  143. return {
  144. isShowAddress: true,
  145. tempSelect: '',
  146. isShowInvoice: true,
  147. content: ''
  148. }
  149. },
  150. methods: {
  151. addstar (item) {
  152. let back = item.substring(7, 12)
  153. let font = item.substring(0, 3)
  154. return font + '*****' + back
  155. },
  156. async getInfo () {
  157. let res = await this.$http
  158. .post('/user/camera/deadline', {}, {
  159. headers: {
  160. token: this.token
  161. }
  162. })
  163. let data = res.data
  164. if (data.code !== 0) {
  165. return false
  166. }
  167. this.content = data.data
  168. },
  169. getCurrentStatus (data) {
  170. this.tempSelect = data
  171. },
  172. update (e) {
  173. let file = e.target.files[0]
  174. let type = file.type.toLowerCase()
  175. if (type !== 'image/jpeg' && type !== 'image/png') {
  176. return this.$toast.show('warn', '上传的图片类型不正确,请重新上传')
  177. }
  178. let token = this.token
  179. let config = {
  180. headers: {
  181. token
  182. }
  183. } // 添加请求头
  184. var reader = new FileReader()
  185. reader.onload = async e => {
  186. let imgdata = e.target.result
  187. let res = await this.$http.post('/user/uploadHead', { imgdata }, config)
  188. if (res.data.code === 0) {
  189. this.info.head = res.data.msg
  190. localStorage.setItem('info', JSON.stringify(this.info))
  191. } else {
  192. this.$toast.show('warn', '上传失败,请稍后再试')
  193. }
  194. }
  195. reader.readAsDataURL(file)
  196. }
  197. },
  198. mounted () {
  199. this.getInfo()
  200. this.$store.dispatch('getInfo', {
  201. url: '/user/getReceiverInfo',
  202. name: 'address'
  203. })
  204. Object.keys(this.invoice2).length === 0 && this.$store.dispatch('getInvoice', {
  205. type: 2,
  206. params: {
  207. invoiceType: 2
  208. }
  209. })
  210. Object.keys(this.invoice3).length === 0 && this.$store.dispatch('getInvoice', {
  211. type: 3,
  212. params: {
  213. invoiceType: 3
  214. }
  215. })
  216. }
  217. }
  218. </script>
  219. <style lang="scss" scoped>
  220. @import "./style.scss";
  221. </style>