index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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. </view>
  8. <view class="share-box">
  9. <u-parse :content="shareContent"></u-parse>
  10. <button type="default" @click.stop='showShareModal'>分享</button>
  11. </view>
  12. <view class="share-box" style="height: 200upx;margin-top: 2%;" @longpress="copyCode">
  13. <view>长按复制框内整段文字,打开 [手淘] 即可购买</view>
  14. <view>{{shareCode}}</view>
  15. <button type="default" @click="copyCode">一键复制</button>
  16. </view>
  17. <view class="product-title">产品详情</view>
  18. <view class="rich-text-box" style="padding: 10px;">
  19. <u-parse :content="detailObj.content"></u-parse>
  20. </view>
  21. <!-- <image class="logo-footer" src="/static/detail-bg2.png"></image> -->
  22. <uni-popup ref="popup" type="bottom">
  23. <view class="uni-share">
  24. <view class="uni-share-content">
  25. <button class="uni-share-content-box" open-type="share">
  26. <view class="uni-share-content-image"><image src="/static/userSetIcon.png" class="image" /></view>
  27. <view class="uni-share-content-text">分享给好友</view>
  28. </button>
  29. <button class="uni-share-content-box" @click="goPostShare">
  30. <view class="uni-share-content-image"><image src="/static/share-icon1.png" class="image" /></view>
  31. <view class="uni-share-content-text">海报分享</view>
  32. </button>
  33. </view>
  34. <view class="uni-share-btn" @click="cancelModal()">取消</view>
  35. </view>
  36. </uni-popup>
  37. </view>
  38. </template>
  39. <script>
  40. var md5 = require("../../../common/md5.js");
  41. import uParse from '@/components/gaoyia-parse/parse.vue'
  42. import uniPopup from "@/components/uni-popup/uni-popup.vue";
  43. export default {
  44. components: {
  45. uParse,
  46. uniPopup
  47. },
  48. data() {
  49. return {
  50. title: 'Hello',
  51. detailObj:{},
  52. shareContent:'',
  53. shareCode:''
  54. }
  55. },
  56. onLoad(option) {
  57. this.getDetailInfo(option.detailId);
  58. },
  59. onShareAppMessage() {
  60. return {
  61. title: '分销小助手',
  62. path:'/pages/index/index?inviteId=' + getApp().globalData.user_id
  63. }
  64. },
  65. methods: {
  66. getDetailInfo(dId){
  67. uni.showLoading({
  68. title: '加载中',
  69. });
  70. let that = this;
  71. uni.request({
  72. url: getApp().globalData.shareUrl, //需要设置为全局
  73. method: 'POST',
  74. header: {
  75. 'content-type': 'application/x-www-form-urlencoded'
  76. },
  77. data: {
  78. method: 'getProductsInfo',
  79. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  80. id: dId,
  81. sign: md5('getProductsInfo' + getApp().globalData.globalTimestamp)
  82. },
  83. success: res => {
  84. if (res.data.code === 200) {
  85. uni.hideLoading();
  86. that.detailObj = res.data.msg;
  87. that.shareContent = getApp().globalData.shareContent;
  88. that.shareCode = getApp().globalData.shareTaobaoCode
  89. console.log(that.shareContent)
  90. }
  91. }
  92. });
  93. },
  94. showShareModal(){
  95. this.$refs.popup.open();
  96. },
  97. cancelModal(){
  98. // 需要在 popup 组件,指定 ref 为 popup
  99. this.$refs.popup.close();
  100. },
  101. goPostShare() {
  102. this.$refs.popup.close()
  103. uni.navigateTo({
  104. url: '/pages/index/postShare/index'
  105. })
  106. },
  107. copyCode(){
  108. let that = this;
  109. uni.setClipboardData({
  110. data:that.shareCode,
  111. success() {
  112. uni.showToast({
  113. icon:'none',
  114. title:'复制成功'
  115. })
  116. }
  117. })
  118. }
  119. }
  120. }
  121. </script>
  122. <style>
  123. @import url("../../../components/gaoyia-parse/parse.css");
  124. .content {
  125. display: flex;
  126. flex-direction: column;
  127. align-items: center;
  128. justify-content: center;
  129. }
  130. .logo {
  131. height: 200px;
  132. width: 100%;
  133. }
  134. .logo-footer {
  135. height: 500px;
  136. width: 100%;
  137. }
  138. .detail-title {
  139. padding: 5px;
  140. margin-bottom: 2%;
  141. width: 100%;
  142. height: 160rpx;
  143. display: flex;
  144. flex-direction: column;
  145. justify-content: space-around;
  146. /* align-items: center; */
  147. background: #fff;
  148. font-size: 30rpx;
  149. }
  150. .detail-font {
  151. display: -webkit-box;
  152. overflow: hidden;
  153. text-overflow: ellipsis;
  154. word-wrap: break-word;
  155. white-space: normal !important;
  156. -webkit-line-clamp: 3;
  157. -webkit-box-orient: vertical;
  158. font-size: 14px;
  159. margin-left: 5%;
  160. }
  161. .price-style {
  162. /* margin-right: 75%; */
  163. margin-left: 4.5%;
  164. color: red;
  165. }
  166. .share-box {
  167. display: flex;
  168. flex-direction: column;
  169. justify-content: center;
  170. align-items: center;
  171. width: 80%;
  172. height: 300upx;
  173. border: 1px dashed red;
  174. background: #fff;
  175. font-size: 28rpx;
  176. padding: 5px;
  177. }
  178. .share-box button {
  179. width: 300rpx;
  180. height: 70rpx;
  181. line-height: 70rpx;
  182. margin-top: 2%;
  183. background-color: #27BCEF;
  184. color: #fff;
  185. }
  186. .title {
  187. font-size: 36upx;
  188. color: #8f8f94;
  189. }
  190. .product-title {
  191. margin-top: 2%;
  192. margin-bottom: 2%;
  193. font-size: 32rpx;
  194. }
  195. .rich-text-box {
  196. font-size: 30rpx;
  197. background: #fff;
  198. display: flex;
  199. flex-direction: column;
  200. align-items: center;
  201. }
  202. /* //分享模态框 */
  203. .uni-share-content {
  204. display: flex;
  205. flex-wrap: wrap;
  206. padding: 15px;
  207. /* justify-content: center */
  208. }
  209. .uni-share-content-box {
  210. display: flex;
  211. flex-direction: column;
  212. align-items: center;
  213. width: 25%;
  214. box-sizing: border-box;
  215. margin-left: 0;
  216. margin-right: 0;
  217. border: none;
  218. background: transparent;
  219. padding-left: 0;
  220. padding-right: 0;
  221. }
  222. .uni-share-content-box::after{
  223. border: none;
  224. }
  225. .uni-share-content-image {
  226. display: flex;
  227. justify-content: center;
  228. align-items: center;
  229. width: 60upx;
  230. height: 60upx;
  231. overflow: hidden;
  232. border-radius: 10upx;
  233. }
  234. .uni-share-content-image .image {
  235. width: 100%;
  236. height: 100%;
  237. }
  238. .uni-share-content-text {
  239. font-size: 26upx;
  240. color: #999;
  241. padding-top: 5px;
  242. // padding-bottom: 10px;
  243. }
  244. .uni-share-btn {
  245. height: 90upx;
  246. line-height: 90upx;
  247. border-top: 1px #f5f5f5 solid;
  248. text-align: center;
  249. color: #666;
  250. font-size: 30rpx;
  251. }
  252. </style>