index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <view class="content">
  3. <image class="logo" :src="detailObj.picture" mode='aspectFill'></image>
  4. <view class="detail-title">
  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">
  21. <view class="left-box">
  22. <image :src="detailObj.picture" 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. }
  71. },
  72. onLoad(option) {
  73. this.getDetailInfo(option.detailId);
  74. },
  75. onShareAppMessage() {
  76. return {
  77. title: '分销小助手',
  78. path:'/pages/index/index?inviteId=' + getApp().globalData.user_id
  79. }
  80. },
  81. methods: {
  82. getDetailInfo(dId){
  83. uni.showLoading({
  84. title: '加载中',
  85. });
  86. let that = this;
  87. uni.request({
  88. url: getApp().globalData.shareUrl, //需要设置为全局
  89. method: 'POST',
  90. header: {
  91. 'content-type': 'application/x-www-form-urlencoded'
  92. },
  93. data: {
  94. method: 'getProductsInfo',
  95. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  96. id: dId,
  97. sign: md5('getProductsInfo' + getApp().globalData.globalTimestamp)
  98. },
  99. success: res => {
  100. if (res.data.code === 200) {
  101. uni.hideLoading();
  102. that.detailObj = res.data.msg;
  103. that.shareContent = getApp().globalData.shareContent;
  104. that.shareCode = getApp().globalData.shareTaobaoCode
  105. console.log(that.shareContent)
  106. }
  107. }
  108. });
  109. },
  110. showShareModal(){
  111. this.$refs.popup.open();
  112. },
  113. cancelModal(){
  114. // 需要在 popup 组件,指定 ref 为 popup
  115. this.$refs.popup.close();
  116. },
  117. goPostShare() {
  118. this.$refs.popup.close()
  119. uni.navigateTo({
  120. url: '/pages/index/postShare/index'
  121. })
  122. },
  123. goRuleList(){
  124. uni.navigateTo({
  125. url: '/pages/index/ruleList/index',
  126. success: res => {},
  127. fail: () => {},
  128. complete: () => {}
  129. });
  130. },
  131. copyCode(){
  132. let that = this;
  133. uni.setClipboardData({
  134. data:that.shareCode,
  135. success() {
  136. uni.showToast({
  137. icon:'none',
  138. title:'复制成功'
  139. })
  140. }
  141. })
  142. },
  143. copyTitle(){
  144. let that = this;
  145. uni.setClipboardData({
  146. data:that.detailObj.desc,
  147. success() {
  148. uni.showToast({
  149. icon:'none',
  150. title:'复制成功'
  151. })
  152. }
  153. })
  154. }
  155. }
  156. }
  157. </script>
  158. <style>
  159. @import url("../../../components/gaoyia-parse/parse.css");
  160. .content {
  161. display: flex;
  162. flex-direction: column;
  163. align-items: center;
  164. justify-content: center;
  165. }
  166. .logo {
  167. height: 200px;
  168. width: 100%;
  169. }
  170. .logo-footer {
  171. height: 500px;
  172. width: 100%;
  173. }
  174. .detail-title {
  175. padding: 5px;
  176. margin-bottom: 2%;
  177. width: 100%;
  178. height: 160rpx;
  179. display: flex;
  180. flex-direction: column;
  181. justify-content: space-around;
  182. /* align-items: center; */
  183. background: #fff;
  184. font-size: 30rpx;
  185. position: relative;
  186. }
  187. .detail-font {
  188. display: -webkit-box;
  189. overflow: hidden;
  190. text-overflow: ellipsis;
  191. word-wrap: break-word;
  192. white-space: normal !important;
  193. -webkit-line-clamp: 3;
  194. -webkit-box-orient: vertical;
  195. font-size: 14px;
  196. margin-left: 5%;
  197. }
  198. .price-style {
  199. /* margin-right: 75%; */
  200. margin-left: 4.5%;
  201. color: red;
  202. }
  203. .share-box-new {
  204. display: flex;
  205. justify-content: space-between;
  206. align-items: center;
  207. width: 100%;
  208. height: 100upx;
  209. background: #fff;
  210. font-size: 28rpx;
  211. padding: 5px;
  212. margin-top: 2%;
  213. }
  214. .left-box {
  215. margin-left: 3%;
  216. display: flex;
  217. align-items: center;
  218. width: 70%;
  219. }
  220. .share-box-new image {
  221. width: 80upx;
  222. height:80upx;
  223. border-radius: 50%;
  224. margin-right: 1%;
  225. }
  226. .share-box {
  227. display: flex;
  228. flex-direction: column;
  229. justify-content: center;
  230. align-items: center;
  231. width: 80%;
  232. height: 300upx;
  233. border: 1px dashed red;
  234. background: #fff;
  235. font-size: 28rpx;
  236. padding: 5px;
  237. }
  238. .share-box button {
  239. width: 300rpx;
  240. height: 70rpx;
  241. line-height: 70rpx;
  242. margin-top: 2%;
  243. background-color: #27BCEF;
  244. color: #fff;
  245. }
  246. .copy-title-btn{
  247. position: absolute;
  248. width: 180rpx;
  249. height: 70rpx;
  250. line-height: 70rpx;
  251. background-color: #27BCEF!important;
  252. color: #fff!important;
  253. font-size: 28rpx;
  254. right: 10px;
  255. top: 45px;
  256. }
  257. .copy-content-btn {
  258. width: 140rpx;
  259. height: 50rpx;
  260. line-height: 50rpx;
  261. background-color: #27BCEF!important;
  262. color: #fff!important;
  263. font-size: 26rpx;
  264. padding-left: 1%;
  265. padding-right: 1%;
  266. }
  267. .title {
  268. font-size: 36upx;
  269. color: #8f8f94;
  270. }
  271. .product-title {
  272. margin-top: 2%;
  273. margin-bottom: 2%;
  274. font-size: 32rpx;
  275. }
  276. .rich-text-box {
  277. font-size: 30rpx;
  278. background: #fff;
  279. display: flex;
  280. flex-direction: column;
  281. align-items: center;
  282. }
  283. /* //分享模态框 */
  284. .uni-share-content {
  285. display: flex;
  286. flex-wrap: wrap;
  287. padding: 15px;
  288. /* justify-content: center */
  289. }
  290. .uni-share-content-box {
  291. display: flex;
  292. flex-direction: column;
  293. align-items: center;
  294. width: 25%;
  295. box-sizing: border-box;
  296. margin-left: 0;
  297. margin-right: 0;
  298. border: none;
  299. background: transparent;
  300. padding-left: 0;
  301. padding-right: 0;
  302. }
  303. .uni-share-content-box::after{
  304. border: none;
  305. }
  306. .uni-share-content-image {
  307. display: flex;
  308. justify-content: center;
  309. align-items: center;
  310. width: 60upx;
  311. height: 60upx;
  312. overflow: hidden;
  313. border-radius: 10upx;
  314. }
  315. .uni-share-content-image .image {
  316. width: 100%;
  317. height: 100%;
  318. }
  319. .uni-share-content-text {
  320. font-size: 26upx;
  321. color: #999;
  322. padding-top: 5px;
  323. // padding-bottom: 10px;
  324. }
  325. .uni-share-btn {
  326. height: 90upx;
  327. line-height: 90upx;
  328. border-top: 1px #f5f5f5 solid;
  329. text-align: center;
  330. color: #666;
  331. font-size: 30rpx;
  332. }
  333. </style>