enterprise_detail.vue 13 KB

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