EnterpriseInfo.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <div id="recommend-fragment-self">
  3. <div class="recommend-product">
  4. <ul>
  5. <li>
  6. <div>
  7. <div class="information-list" v-if="storeInfo.enterprise.address" :title="storeInfo.enterprise.address">
  8. <div>官网地址&nbsp;:</div><div>{{storeInfo.enterprise.address | addressFilter}}</div>
  9. </div>
  10. <div class="information-list" v-if="storeInfo.enterprise.enAddress" :title="storeInfo.enterprise.enAddress">
  11. <div>地址&nbsp;:</div><div>{{storeInfo.enterprise.enAddress | enAddressFilter}}</div>
  12. </div>
  13. <div class="information-list" v-if="storeInfo.enterprise.enTel">
  14. <div>电话&nbsp;:</div><div>{{storeInfo.enterprise.enTel}}</div>
  15. </div>
  16. <div class="information-list" v-if="storeInfo.enterprise.enFax">
  17. <div>传真&nbsp;:</div><div>{{storeInfo.enterprise.enFax}}</div>
  18. </div>
  19. <div class="information-list">
  20. <div>资质审核&nbsp;:</div><div>营业执照&nbsp;&nbsp;<img src="/images/store/home/logo-qualification.jpg"></div>
  21. </div>
  22. <div class="introduce">
  23. <h4>企业简介</h4>
  24. <p>{{storeInfo.description}}</p>
  25. </div>
  26. </div>
  27. </li>
  28. <li>
  29. <div style="width: 966px; height: 356px; margin-left: 3px;">
  30. <recommend-list></recommend-list>
  31. </div>
  32. </li>
  33. </ul>
  34. </div>
  35. <div class="shadow"><img src="/images/store/common/shadow.png"></div>
  36. </div>
  37. </template>
  38. <script>
  39. import Buy from '~components/common/buyOrCar/buyComponent.vue'
  40. import RecommendList from './RecommendList.vue'
  41. export default {
  42. name: 'product-recommend-self',
  43. components: {
  44. RecommendList,
  45. Buy
  46. },
  47. computed: {
  48. commodities () {
  49. return this.$store.state.shop.recommend.products.data
  50. },
  51. storeInfo () {
  52. return this.$store.state.shop.storeInfo.store.data
  53. }
  54. },
  55. filters: {
  56. addressFilter: function (title) {
  57. if (title === '') {
  58. return title
  59. }
  60. let len = 0
  61. let index = 0
  62. for (let i = 0; i < title.length; i++) {
  63. if (index === 0 && title.charAt(i).charCodeAt(0) > 255) {
  64. len = len + 2
  65. } else {
  66. len++
  67. }
  68. if (len > 20) {
  69. index = i
  70. break
  71. }
  72. }
  73. if (index > 0) {
  74. return title.substring(0, index) + '...'
  75. } else {
  76. return title
  77. }
  78. },
  79. enaddressFilter: function (title) {
  80. if (title === '') {
  81. return title
  82. }
  83. let len = 0
  84. let index = 0
  85. for (let i = 0; i < title.length; i++) {
  86. if (index === 0 && title.charAt(i).charCodeAt(0) > 255) {
  87. len = len + 2
  88. } else {
  89. len++
  90. }
  91. if (len > 50) {
  92. index = i
  93. break
  94. }
  95. }
  96. if (index > 0) {
  97. return title.substring(0, index) + '...'
  98. } else {
  99. return title
  100. }
  101. }
  102. },
  103. methods: {
  104. buyNow: function (isBuy, item) {
  105. if (!this.$store.state.option.user.logged) {
  106. this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
  107. if (response.data) {
  108. this.$router.push('/auth/login')
  109. }
  110. })
  111. } else {
  112. if (item) {
  113. if (isBuy) {
  114. this.$http.post('trade/order/buyNow', [{
  115. uuid: item.comUuid,
  116. batchCode: item.batchCode,
  117. number: item.minBuyQty,
  118. storeid: item.storeId,
  119. storeUuid: item.storeUuid,
  120. currencyName: item.currency,
  121. minPackQty: item.minPackQty ? item.minPackQty : item.minBuyQty
  122. }])
  123. .then(response => {
  124. // window.location.href = '/user#/order/pay/' + this.enidfilter(response.data.orderid)
  125. if (response.data.success) {
  126. if (response.data.message) {
  127. this.$message({
  128. message: response.data.message,
  129. type: 'success'
  130. })
  131. let _self = this
  132. window.setTimeout(function () {
  133. window.location.href = '/user#/order/pay/' + _self.enidfilter(response.data.data.orderid)
  134. }, 1000)
  135. } else {
  136. window.location.href = '/user#/order/pay/' + this.enidfilter(response.data.data.orderid)
  137. }
  138. } else {
  139. if (response.data.data && response.data.data.unvailable === 1) {
  140. this.$message.error('产品信息已失效,请刷新界面')
  141. } else {
  142. this.$message.error(response.data.message)
  143. }
  144. }
  145. }, err => {
  146. console.log(err)
  147. if (item.minBuyQty > item.reserve) {
  148. this.$message.error('商品' + item.code + '的库存已经不满足起订量')
  149. }
  150. })
  151. } else {
  152. // this.$store.dispatch('user/addCar', {uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty})
  153. this.$http.post('trade/cart/add', {
  154. uuid: item.comUuid,
  155. batchCode: item.batchCode,
  156. number: item.minBuyQty,
  157. storeid: item.storeId,
  158. storeUuid: item.storeUuid,
  159. currencyName: item.currency,
  160. minPackQty: item.minPackQty ? item.minPackQty : item.minBuyQty
  161. })
  162. .then(response => {
  163. if (response.data.success) {
  164. if (response.data.message) {
  165. this.$message({
  166. message: '添加购物车成功,但商品信息有更新',
  167. type: 'success'
  168. })
  169. } else {
  170. this.$message({
  171. message: '添加购物车成功',
  172. type: 'success'
  173. })
  174. }
  175. } else {
  176. this.$message.error(response.data.message)
  177. }
  178. })
  179. }
  180. }
  181. }
  182. },
  183. enidfilter: function (str) {
  184. if (str) {
  185. let encryptStr = '' // 最终返回的加密后的字符串
  186. // 产生三位随机数
  187. let num = ''
  188. for (let i = 0; i < 3; i++) {
  189. num += Math.floor(Math.random() * 10)
  190. }
  191. encryptStr += num // 产生3位随机数
  192. // 16位加密
  193. let tempspit = ''
  194. let strspit = str.toString().toLowerCase()
  195. if (strspit.match(/^[-+]?\d*$/) === null) { // 非整数字符,对每一个字符都转换成16进制,然后拼接
  196. /**
  197. * Unicode汉字、英文字母、数字的unicode范围
  198. *汉字:[0x4e00,0x9fa5](或十进制[19968,40869])
  199. *数字:[0x30,0x39](或十进制[48, 57])
  200. *小写字母:[0x61,0x7a](或十进制[97, 122])
  201. *大写字母:[0x41,0x5a](或十进制[65, 90]
  202. * 'a'的Unicode编码:'&#97;',charCodeAt()的值是97
  203. * '码'的Unicode编码:'\u7801', new String('码').charCodeAt()的值是30721,30721的16进制表示是7801
  204. */
  205. let s = strspit.split('')
  206. for (let i = 0; i < s.length; i++) {
  207. s[i] = s[i].charCodeAt() // 先转换成Unicode编码
  208. s[i] = s[i].toString(16)
  209. // 因为在服务器是每两位当做一个字符进行解析的,所以这里每个字符的Unicode编码范围必须在0——255之间。数字和大小写满足该要求,特殊字符则不一定,如果后续有特殊字符的要求,需要重写编码器和解码器
  210. if (s[i].length === 1) {
  211. s[i] = '0' + s[i]
  212. }
  213. tempspit = tempspit + s[i]
  214. }
  215. tempspit = tempspit + '{' + 1 // 1代表字符
  216. } else { // 数字直接转换成16进制
  217. strspit = parseInt(strspit)
  218. .toString(16)
  219. tempspit = strspit + '{' + 0 // 0代表纯数字
  220. }
  221. let temp = tempspit.split('{') // 对要加密的字符转换成16进制
  222. let numLength = temp[0].length // 转换后的字符长度
  223. numLength = numLength.toString(16) // 字符长度换算成16进制
  224. if (numLength.length === 1) { // 如果是1,补一个0
  225. numLength = '0' + numLength
  226. } else if (numLength.length > 3) { // 转换后的16进制字符长度如果大于2位数,则返回,不支持
  227. return ''
  228. }
  229. encryptStr += numLength
  230. if (temp[1] === '0') {
  231. encryptStr += 0
  232. } else if (temp[1] === '1') {
  233. encryptStr += 1
  234. }
  235. encryptStr += temp[0]
  236. if (encryptStr.length < 20) { // 如果小于20位,补上随机数
  237. // 产生三位随机数
  238. let numtwo = ''
  239. for (let i = 0; i < 20 - encryptStr.length; i++) {
  240. numtwo += Math.floor(Math.random() * 10)
  241. }
  242. let ran = numtwo // 产生3位随机数
  243. encryptStr += ran
  244. }
  245. return encryptStr
  246. }
  247. }
  248. }
  249. }
  250. </script>
  251. <style lang="scss" scoped>
  252. #recommend-fragment-self {
  253. min-width: 1190px;
  254. background: #ece9ec;
  255. margin: 0 auto;
  256. margin:-18px 0px -40px 0px;
  257. .recommend-product {
  258. width: 1190px;
  259. height: 356px;
  260. margin: 0 auto;
  261. ul {
  262. width: 100%;
  263. height: 356px;
  264. /*overflow: hidden;*/
  265. li {
  266. position: relative;
  267. float: left;
  268. &:first-child {
  269. width: 220px;
  270. height: 356px;
  271. background: #fff;
  272. padding-top: 20px;
  273. border-radius: 5px;
  274. .information-list {
  275. font-size: 12px;
  276. color: #333;
  277. div:first-child {
  278. width: 72px;
  279. text-align: right;
  280. line-height: 20px;
  281. }
  282. div:last-child {
  283. width: 158px;
  284. line-height: 20px;
  285. padding: 0px 10px 0px 6px;
  286. }
  287. }
  288. .information-list > div {
  289. display: table-cell;
  290. }
  291. .introduce {
  292. width: 250px;
  293. height: 188px;
  294. font-size: 12px;
  295. line-height: 15px;
  296. color: #333;
  297. h4 {
  298. background: url("/images/store/home/detail1.png") no-repeat 6% 10%;
  299. font-size: 14px;
  300. padding: 0px 0px 5px 30px;
  301. }
  302. p {
  303. margin: -15px 0px 0px 15px;
  304. text-indent: 2em;
  305. overflow-y: auto;
  306. overflow-x: hidden;
  307. width: 200px;
  308. line-height: 19px;
  309. max-height: 153px;
  310. }
  311. }
  312. }
  313. }
  314. }
  315. }
  316. .shadow {
  317. width: 1190px;
  318. margin: 0 auto;
  319. img {
  320. position: relative;
  321. top: -10px;
  322. }
  323. }
  324. }
  325. </style>