index.vue 6.3 KB

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