EnterpriseInfo.vue 12 KB

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