enterprise_detail.vue 11 KB

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