enterprise_detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. <template>
  2. <view class="content" :class="{ 'margin-bottom-80': isMar }" v-if="isShow">
  3. <view class="title">
  4. <view class="logo">
  5. <image :src="'https://kiq.xazhima.com' + info.pic_url" alt=""></image>
  6. </view>
  7. <view class="name">
  8. {{ info.name }}
  9. </view>
  10. </view>
  11. <view class="enterprise-item-box">
  12. <view
  13. v-for="(item, idx) in titleList"
  14. :key="idx"
  15. :class="{ active: active === idx }"
  16. class="enterprise-item-name"
  17. @click="change(idx)"
  18. >
  19. {{ item }}
  20. </view>
  21. </view>
  22. <view class="baseInfo" v-if="active === 0">
  23. <view class="card-title">{{ model.title }}</view>
  24. <view class="item-list">
  25. <view v-for="(item, idx) in model.item" :key="idx" class="term">
  26. <view class="term-name">{{ item.name }}:</view>
  27. <view class="term-value-group" v-if="item.name !== '网址'">
  28. <p
  29. v-for="(value, idx) in item.value"
  30. :key="idx"
  31. class="term-value-item"
  32. :class="{ blue: item.name == '电话' }"
  33. >
  34. {{ value }}
  35. </p>
  36. </view>
  37. <view
  38. class="term-value-group"
  39. v-else
  40. style="
  41. flex-direction: row;
  42. align-items: center;
  43. padding-left: 20rpx;
  44. "
  45. >
  46. <view class="flex_i">
  47. <view class="">
  48. {{ item.value[0] }}
  49. </view>
  50. <view
  51. class="copy"
  52. @click="copy(item.value[0])"
  53. style="color: #02a7f0; margin-left: 15rpx"
  54. >复制</view
  55. >
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <view v-else-if="active === 1" class="proInfo">
  62. <view class="products" v-if="productList.length !== 0">
  63. <view
  64. class="product"
  65. @click="toDetail(item.id)"
  66. v-for="(item, idx) in productList"
  67. :key="idx"
  68. >
  69. <view class="img">
  70. <image :src="'https://kiq.xazhima.com' + item.pic_url"></image>
  71. </view>
  72. <view class="name">{{ item.name }}</view>
  73. </view>
  74. </view>
  75. <view v-else class="products">
  76. <img src="/static/nodata.svg" alt="" />
  77. <div style="margin: 0 auto">暂无产品信息</div>
  78. </view>
  79. </view>
  80. <view style="width: 100%">
  81. <footer-share
  82. style="width: 100%"
  83. :isCollection="true"
  84. :isCollectedIcon="infoObj.if_collect"
  85. @collectionPages="collectionPage"
  86. @sharePages="sharePage"
  87. ></footer-share>
  88. </view>
  89. </view>
  90. </template>
  91. <script>
  92. import md5 from "@/common/md5.js";
  93. import topTitle from "@/components/top-title/top-title.vue";
  94. import footTabs from "@/components/foot-tabs/footTabs.vue";
  95. export default {
  96. components: {
  97. "foot-tabs": footTabs,
  98. "top-title": topTitle,
  99. },
  100. data() {
  101. return {
  102. id: "",
  103. scrollTop: 0,
  104. titleList: ["基本信息", "产品信息"],
  105. active: 0,
  106. info: {},
  107. model: {},
  108. productList: [],
  109. isShow: false,
  110. infoObj: {},
  111. };
  112. },
  113. onLoad(option) {
  114. let id = option.id;
  115. this.getCompanyInfo(id);
  116. this.getProductInfo(id);
  117. },
  118. methods: {
  119. change(idx) {
  120. this.active = idx;
  121. },
  122. toDetail(index) {
  123. uni.navigateTo({
  124. url: "/pages/enterprise/product_detail?id=" + index,
  125. });
  126. },
  127. getCompanyInfo(id) {
  128. let md5Sign = md5(
  129. "method=" +
  130. "common" +
  131. "&timestamp=" +
  132. getApp().globalData.globalTimestamp +
  133. "&secret=" +
  134. getApp().globalData.secret
  135. );
  136. let url =
  137. getApp().globalData.shareUrl +
  138. "api/api.php" +
  139. "?method=common&source=company&action=info_by_id&timestamp=" +
  140. getApp().globalData.globalTimestamp +
  141. "&sign=" +
  142. md5Sign;
  143. uni.request({
  144. url: url,
  145. method: "POST",
  146. header: {
  147. "content-type": "application/x-www-form-urlencoded",
  148. },
  149. data: { id, openId: getApp().globalData.open_id },
  150. success: (res) => {
  151. if (res.data.code === 200) {
  152. this.infoObj = res.data.data;
  153. let {
  154. name,
  155. pic_url,
  156. representative,
  157. found_date,
  158. capital,
  159. code,
  160. industry_name,
  161. park_name,
  162. work_address,
  163. rigiser_address,
  164. web_url,
  165. phone,
  166. work_range,
  167. } = res.data.data;
  168. this.info = {
  169. name,
  170. pic_url,
  171. representative,
  172. found_date,
  173. capital,
  174. code,
  175. industry_name,
  176. park_name,
  177. work_address,
  178. rigiser_address,
  179. web_url,
  180. phone,
  181. work_range,
  182. };
  183. this.model = {
  184. title: '',
  185. item: [
  186. {
  187. name: "法定代表人",
  188. value: [this.info.representative],
  189. },
  190. {
  191. name: "成立日期",
  192. value: [this.info.found_date],
  193. },
  194. {
  195. name: "注册资本",
  196. value: [this.info.capital],
  197. },
  198. {
  199. name: "统一社会信用代码",
  200. value: [this.info.code],
  201. },
  202. {
  203. name: "所属行业",
  204. value: [this.info.industry_name],
  205. },
  206. {
  207. name: "所属园区",
  208. value: [this.info.park_name],
  209. },
  210. {
  211. name: "经营范围",
  212. value: [this.info.work_range],
  213. },
  214. {
  215. name: "地址",
  216. value: [this.info.rigiser_address],
  217. },
  218. {
  219. name: "网址",
  220. value: [this.info.web_url],
  221. },
  222. {
  223. name: "电话",
  224. value: [this.info.phone],
  225. },
  226. ],
  227. };
  228. getApp().globalData.company_name = name
  229. getApp().globalData.company_logo = 'https://kiq.xazhima.com'+pic_url
  230. this.isShow = true;
  231. }
  232. },
  233. fail: () => {
  234. console.log("连接失败");
  235. },
  236. });
  237. },
  238. getProductInfo(id) {
  239. let md5Sign = md5(
  240. "method=" +
  241. "common" +
  242. "&timestamp=" +
  243. getApp().globalData.globalTimestamp +
  244. "&secret=" +
  245. getApp().globalData.secret
  246. );
  247. let url =
  248. getApp().globalData.shareUrl +
  249. "api/api.php" +
  250. "?method=common&action=list&source=company_product&timestamp=" +
  251. getApp().globalData.globalTimestamp +
  252. "&sign=" +
  253. md5Sign;
  254. uni.request({
  255. url: url,
  256. method: "POST",
  257. header: {
  258. "content-type": "application/x-www-form-urlencoded",
  259. },
  260. data: {
  261. s_company_id: id,
  262. },
  263. success: (res) => {
  264. if (res.data.code === 200) {
  265. this.productList = res.data.data.list;
  266. console.log(this.productList);
  267. }
  268. },
  269. fail: () => {
  270. console.log("连接失败");
  271. },
  272. });
  273. },
  274. goAuthPage() {
  275. uni.navigateTo({
  276. url: "../auth/index",
  277. });
  278. },
  279. collectionPage() {
  280. if (!getApp().globalData.user_phone) {
  281. this.goAuthPage();
  282. return;
  283. }
  284. let md5Sign = md5(
  285. "method=" +
  286. "user" +
  287. "&timestamp=" +
  288. getApp().globalData.globalTimestamp +
  289. "&secret=" +
  290. getApp().globalData.secret
  291. );
  292. let url =
  293. getApp().globalData.shareUrl +
  294. "api/api.php" +
  295. "?method=user&source=company&action=collect_add&timestamp=" +
  296. getApp().globalData.globalTimestamp +
  297. "&sign=" +
  298. md5Sign;
  299. uni.request({
  300. url: url,
  301. method: "POST",
  302. header: {
  303. "content-type": "application/x-www-form-urlencoded",
  304. },
  305. data: {
  306. openId: getApp().globalData.open_id,
  307. source: "company",
  308. source_name: "企业",
  309. source_id: this.infoObj.id,
  310. source_title: this.infoObj.name,
  311. },
  312. success: (res) => {
  313. if (res.data.code === 200) {
  314. res.data.data
  315. ? (this.infoObj.if_collect = true)
  316. : (this.infoObj.if_collect = false);
  317. this.$forceUpdate();
  318. uni.showToast({
  319. duration: 3000,
  320. title: res.data.msg,
  321. icon: "none",
  322. });
  323. }
  324. },
  325. fail: () => {
  326. console.log("连接失败");
  327. },
  328. });
  329. },
  330. shareRequest() {
  331. let md5Sign = md5(
  332. "method=" +
  333. "user" +
  334. "&timestamp=" +
  335. getApp().globalData.globalTimestamp +
  336. "&secret=" +
  337. getApp().globalData.secret
  338. );
  339. let url =
  340. getApp().globalData.shareUrl +
  341. "api/api.php" +
  342. "?method=user&source=company&action=repost&timestamp=" +
  343. getApp().globalData.globalTimestamp +
  344. "&sign=" +
  345. md5Sign;
  346. uni.request({
  347. url: url,
  348. method: "POST",
  349. header: {
  350. "content-type": "application/x-www-form-urlencoded",
  351. },
  352. data: {
  353. openId: getApp().globalData.open_id,
  354. source_id: this.infoObj.id,
  355. source: "company",
  356. },
  357. success: (res) => {
  358. if (res.data.code === 200) {
  359. console.log(res);
  360. }
  361. },
  362. fail: () => {
  363. console.log("连接失败");
  364. },
  365. });
  366. },
  367. sharePage() {
  368. let that = this;
  369. uni.showShareMenu({
  370. title: that.infoObj.title,
  371. path: "pages/enterprise/enterprise_detail?id=" + that.infoObj.id,
  372. success(res) {
  373. that.shareRequest();
  374. },
  375. });
  376. },
  377. copy(data) {
  378. uni.setClipboardData({
  379. data,
  380. success: function () {
  381. console.log("复制成功");
  382. },
  383. });
  384. },
  385. },
  386. };
  387. </script>
  388. <style lang="scss" scoped>
  389. .content {
  390. padding: 4%;
  391. font-size: 30rpx;
  392. .blue {
  393. color: #02a7f0;
  394. }
  395. .title {
  396. display: flex;
  397. align-items: center;
  398. border-radius: 10rpx;
  399. margin-bottom: 50rpx;
  400. box-shadow: rgba(0, 0, 0, 0.35) 0rpx 5rpx 15rpx;
  401. height: 150rpx;
  402. .logo {
  403. image {
  404. width: 100rpx;
  405. height: 100rpx;
  406. margin: 0 30rpx;
  407. }
  408. }
  409. }
  410. .baseInfo {
  411. margin-bottom: 50rpx;
  412. .card-title {
  413. padding: 20rpx 20rpx 0rpx 20rpx;
  414. font-weight: 600;
  415. }
  416. .item-list {
  417. margin-left: 20rpx;
  418. display: flex;
  419. flex-direction: column;
  420. .term {
  421. display: flex;
  422. .term-name {
  423. font-size: 27rpx;
  424. width: 30%;
  425. display: flex;
  426. margin: 20rpx;
  427. color: #7f7f7f;
  428. }
  429. .term-value-group {
  430. flex: 1;
  431. display: flex;
  432. flex-direction: column;
  433. font-size: 27rpx;
  434. .term-value-item {
  435. margin: 20rpx;
  436. }
  437. .flex_i {
  438. display: flex;
  439. flex-flow: row;
  440. justify-content: space-around;
  441. }
  442. }
  443. }
  444. }
  445. }
  446. .proInfo {
  447. font-size: 25rpx;
  448. .products {
  449. width: 100%;
  450. display: flex;
  451. padding: 4%;
  452. flex-wrap: wrap;
  453. .product {
  454. margin: 2%;
  455. padding: 2%;
  456. border-radius: 30rpx;
  457. box-shadow: rgba(0, 0, 0, 0.35) 0rpx 5rpx 15rpx;
  458. width: 40%;
  459. height: 100px;
  460. display: flex;
  461. flex-flow: column;
  462. justify-content: space-between;
  463. align-items: center;
  464. .img {
  465. width: 200rpx;
  466. height: 200rpx;
  467. image {
  468. width: 200rpx;
  469. height: 160rpx;
  470. }
  471. }
  472. }
  473. }
  474. }
  475. .enterprise-item-box {
  476. display: flex;
  477. justify-content: space-evenly;
  478. margin: 0 20rpx;
  479. margin-top: 10rpx;
  480. .enterprise-item-name {
  481. padding-bottom: 10rpx;
  482. font-size: 27rpx;
  483. }
  484. .active {
  485. font-weight: 600;
  486. border-bottom: 7rpx solid #02a7f0;
  487. }
  488. }
  489. }
  490. .margin-bottom-80 {
  491. margin-bottom: 80rpx;
  492. }
  493. </style>