index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <template>
  2. <view class="content">
  3. <image class="logo" :src="detailObj.picture" mode='aspectFill'></image>
  4. <view class="detail-title" @longpress="copyTitle">
  5. <text class="detail-font">{{detailObj.desc || '-'}}</text>
  6. <text class="price-style">¥{{detailObj.money || '-'}}</text>
  7. <!-- <button type="default" class="copy-title-btn" @click="copyTitle">复制标题</button> -->
  8. </view>
  9. <view class="share-box">
  10. <u-parse :content="shareContent"></u-parse>
  11. <button type="default" @click.stop='showShareModal'>分享</button>
  12. </view>
  13. <!-- <view class="share-box" style="height: 200upx;margin-top: 2%;" @longpress="copyCode">
  14. <view>长按复制框内整段文字,打开 [手淘] 即可购买</view>
  15. <view style="text-align: center;">{{shareCode}}</view>
  16. <view style="text-align: center;">复制店铺名[{{shareCode || '-'}}],打开[Tao宝]</view>
  17. <view style="text-align: center;">搜索进入</view>
  18. <button type="default" @click="copyCode">一键复制</button>
  19. </view> -->
  20. <view class="share-box-new" @longpress="copyCode">
  21. <view class="left-box">
  22. <image :src="storeImg" mode="aspectFill"></image>
  23. <view>{{shareCode || '-'}}</view>
  24. </view>
  25. <!-- <view style="margin-right: 3%;">
  26. <button type="default" class="copy-content-btn" @click="copyCode">一键复制</button>
  27. </view> -->
  28. </view>
  29. <view class="product-title">产品详情</view>
  30. <view class="rich-text-box" style="padding: 10px;">
  31. <u-parse :content="detailObj.content"></u-parse>
  32. </view>
  33. <!-- <image class="logo-footer" src="/static/detail-bg2.png"></image> -->
  34. <uni-popup ref="popup" type="bottom">
  35. <view class="uni-share">
  36. <view class="uni-share-content">
  37. <button class="uni-share-content-box" open-type="share">
  38. <view class="uni-share-content-image"><image src="/static/userSetIcon.png" class="image" /></view>
  39. <view class="uni-share-content-text">分享给好友</view>
  40. </button>
  41. <button class="uni-share-content-box" @click="goPostShare">
  42. <view class="uni-share-content-image"><image src="/static/share-icon1.png" class="image" /></view>
  43. <view class="uni-share-content-text">海报分享</view>
  44. </button>
  45. <button class="uni-share-content-box" @click="goRuleList">
  46. <view class="uni-share-content-image"><image src="/static/note.png" class="image" /></view>
  47. <view class="uni-share-content-text">分享规则</view>
  48. </button>
  49. </view>
  50. <view class="uni-share-btn" @click="cancelModal()">取消</view>
  51. </view>
  52. </uni-popup>
  53. </view>
  54. </template>
  55. <script>
  56. var md5 = require("../../../common/md5.js");
  57. import uParse from '@/components/gaoyia-parse/parse.vue'
  58. import uniPopup from "@/components/uni-popup/uni-popup.vue";
  59. export default {
  60. components: {
  61. uParse,
  62. uniPopup
  63. },
  64. data() {
  65. return {
  66. title: 'Hello',
  67. detailObj:{},
  68. shareContent:'',
  69. shareCode:'',
  70. storeImg:'',
  71. isAuthPhone:getApp().globalData.user_phone,
  72. }
  73. },
  74. onLoad(option) {
  75. this.getDetailInfo(option.detailId);
  76. },
  77. onShow() {
  78. },
  79. onShareAppMessage() {
  80. return {
  81. title: '分销小助手',
  82. path:'/pages/index/index?scene=' + getApp().globalData.user_id
  83. }
  84. },
  85. methods: {
  86. getDetailInfo(dId){
  87. uni.showLoading({
  88. title: '加载中',
  89. });
  90. let that = this;
  91. uni.request({
  92. url: getApp().globalData.shareUrl, //需要设置为全局
  93. method: 'POST',
  94. header: {
  95. 'content-type': 'application/x-www-form-urlencoded'
  96. },
  97. data: {
  98. method: 'getProductsInfo',
  99. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  100. id: dId,
  101. sign: md5('getProductsInfo' + getApp().globalData.globalTimestamp)
  102. },
  103. success: res => {
  104. if (res.data.code === 200) {
  105. uni.hideLoading();
  106. that.detailObj = res.data.msg;
  107. that.shareContent = getApp().globalData.shareContent;
  108. that.shareCode = getApp().globalData.shareTaobaoCode;
  109. that.storeImg = getApp().globalData.shareStoreImg;
  110. console.log(that.shareContent)
  111. }
  112. }
  113. });
  114. },
  115. showShareModal(){
  116. if(this.isAuthPhone){
  117. this.$refs.popup.open();
  118. }else {
  119. uni.navigateTo({
  120. url: '../../auth/index',
  121. success: res => {},
  122. fail: () => {},
  123. complete: () => {}
  124. });
  125. }
  126. },
  127. cancelModal(){
  128. // 需要在 popup 组件,指定 ref 为 popup
  129. this.$refs.popup.close();
  130. },
  131. goPostShare() {
  132. this.$refs.popup.close()
  133. uni.navigateTo({
  134. url: '/pages/index/postShare/index'
  135. })
  136. },
  137. goRuleList(){
  138. uni.navigateTo({
  139. url: '/pages/index/ruleList/index',
  140. success: res => {},
  141. fail: () => {},
  142. complete: () => {}
  143. });
  144. },
  145. copyCode(){
  146. let that = this;
  147. uni.setClipboardData({
  148. data:that.shareCode,
  149. success() {
  150. uni.showToast({
  151. icon:'none',
  152. title:'复制成功'
  153. })
  154. }
  155. })
  156. },
  157. copyTitle(){
  158. let that = this;
  159. uni.setClipboardData({
  160. data:that.detailObj.desc,
  161. success() {
  162. uni.showToast({
  163. icon:'none',
  164. title:'复制成功'
  165. })
  166. }
  167. })
  168. }
  169. }
  170. }
  171. </script>
  172. <style>
  173. @import url("../../../components/gaoyia-parse/parse.css");
  174. .content {
  175. display: flex;
  176. flex-direction: column;
  177. align-items: center;
  178. justify-content: center;
  179. }
  180. .logo {
  181. height: 200px;
  182. width: 100%;
  183. }
  184. .logo-footer {
  185. height: 500px;
  186. width: 100%;
  187. }
  188. .detail-title {
  189. padding: 5px;
  190. margin-bottom: 2%;
  191. width: 100%;
  192. height: 160rpx;
  193. display: flex;
  194. flex-direction: column;
  195. justify-content: space-around;
  196. /* align-items: center; */
  197. background: #fff;
  198. font-size: 30rpx;
  199. position: relative;
  200. }
  201. .detail-font {
  202. display: -webkit-box;
  203. overflow: hidden;
  204. text-overflow: ellipsis;
  205. word-wrap: break-word;
  206. white-space: normal !important;
  207. -webkit-line-clamp: 3;
  208. -webkit-box-orient: vertical;
  209. font-size: 14px;
  210. margin-left: 5%;
  211. }
  212. .price-style {
  213. /* margin-right: 75%; */
  214. margin-left: 4.5%;
  215. color: red;
  216. }
  217. .share-box-new {
  218. display: flex;
  219. justify-content: space-between;
  220. align-items: center;
  221. width: 100%;
  222. height: 100upx;
  223. background: #fff;
  224. font-size: 28rpx;
  225. padding: 5px;
  226. margin-top: 2%;
  227. }
  228. .left-box {
  229. margin-left: 3%;
  230. display: flex;
  231. align-items: center;
  232. width: 70%;
  233. }
  234. .share-box-new image {
  235. width: 80upx;
  236. height:80upx;
  237. border-radius: 50%;
  238. margin-right: 1%;
  239. }
  240. .share-box {
  241. display: flex;
  242. flex-direction: column;
  243. justify-content: center;
  244. align-items: center;
  245. width: 80%;
  246. height: 300upx;
  247. border: 1px dashed red;
  248. background: #fff;
  249. font-size: 28rpx;
  250. padding: 5px;
  251. }
  252. .share-box button {
  253. width: 300rpx;
  254. height: 70rpx;
  255. line-height: 70rpx;
  256. margin-top: 2%;
  257. background-color: #27BCEF;
  258. color: #fff;
  259. }
  260. .copy-title-btn{
  261. position: absolute;
  262. width: 180rpx;
  263. height: 70rpx;
  264. line-height: 70rpx;
  265. background-color: #27BCEF!important;
  266. color: #fff!important;
  267. font-size: 28rpx;
  268. right: 10px;
  269. top: 45px;
  270. }
  271. .copy-content-btn {
  272. width: 140rpx;
  273. height: 50rpx;
  274. line-height: 50rpx;
  275. background-color: #27BCEF!important;
  276. color: #fff!important;
  277. font-size: 26rpx;
  278. padding-left: 1%;
  279. padding-right: 1%;
  280. }
  281. .title {
  282. font-size: 36upx;
  283. color: #8f8f94;
  284. }
  285. .product-title {
  286. margin-top: 2%;
  287. margin-bottom: 2%;
  288. font-size: 32rpx;
  289. }
  290. .rich-text-box {
  291. font-size: 30rpx;
  292. background: #fff;
  293. display: flex;
  294. flex-direction: column;
  295. align-items: center;
  296. }
  297. /* //分享模态框 */
  298. .uni-share-content {
  299. display: flex;
  300. flex-wrap: wrap;
  301. padding: 15px;
  302. /* justify-content: center */
  303. }
  304. .uni-share-content-box {
  305. display: flex;
  306. flex-direction: column;
  307. align-items: center;
  308. width: 25%;
  309. box-sizing: border-box;
  310. margin-left: 0;
  311. margin-right: 0;
  312. border: none;
  313. background: transparent;
  314. padding-left: 0;
  315. padding-right: 0;
  316. }
  317. .uni-share-content-box::after{
  318. border: none;
  319. }
  320. .uni-share-content-image {
  321. display: flex;
  322. justify-content: center;
  323. align-items: center;
  324. width: 60upx;
  325. height: 60upx;
  326. overflow: hidden;
  327. border-radius: 10upx;
  328. }
  329. .uni-share-content-image .image {
  330. width: 100%;
  331. height: 100%;
  332. }
  333. .uni-share-content-text {
  334. font-size: 26upx;
  335. color: #999;
  336. padding-top: 5px;
  337. // padding-bottom: 10px;
  338. }
  339. .uni-share-btn {
  340. height: 90upx;
  341. line-height: 90upx;
  342. border-top: 1px #f5f5f5 solid;
  343. text-align: center;
  344. color: #666;
  345. font-size: 30rpx;
  346. }
  347. </style>