index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <view class="content">
  3. <image class="logo" :src="detailObj.picture"></image>
  4. <view class="detail-title">
  5. <text style="margin-left: 5%;">{{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>
  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. let that = this;
  68. uni.request({
  69. url: getApp().globalData.shareUrl, //需要设置为全局
  70. method: 'POST',
  71. header: {
  72. 'content-type': 'application/x-www-form-urlencoded'
  73. },
  74. data: {
  75. method: 'getProductsInfo',
  76. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  77. id: dId,
  78. sign: md5('getProductsInfo' + getApp().globalData.globalTimestamp)
  79. },
  80. success: res => {
  81. if (res.data.code === 200) {
  82. that.detailObj = res.data.msg;
  83. that.shareContent = getApp().globalData.shareContent;
  84. that.shareCode = getApp().globalData.shareTaobaoCode
  85. console.log(that.shareContent)
  86. }
  87. }
  88. });
  89. },
  90. showShareModal(){
  91. this.$refs.popup.open();
  92. },
  93. cancelModal(){
  94. // 需要在 popup 组件,指定 ref 为 popup
  95. this.$refs.popup.close();
  96. },
  97. goPostShare() {
  98. this.$refs.popup.close()
  99. uni.navigateTo({
  100. url: '/pages/index/postShare/index'
  101. })
  102. },
  103. copyCode(){
  104. let that = this;
  105. uni.setClipboardData({
  106. data:that.shareCode,
  107. success() {
  108. uni.showToast({
  109. icon:'none',
  110. title:'复制成功'
  111. })
  112. }
  113. })
  114. }
  115. }
  116. }
  117. </script>
  118. <style>
  119. @import url("../../../components/gaoyia-parse/parse.css");
  120. .content {
  121. display: flex;
  122. flex-direction: column;
  123. align-items: center;
  124. justify-content: center;
  125. }
  126. .logo {
  127. height: 200px;
  128. width: 100%;
  129. }
  130. .logo-footer {
  131. height: 500px;
  132. width: 100%;
  133. }
  134. .detail-title {
  135. padding: 10px;
  136. margin-bottom: 2%;
  137. width: 100%;
  138. height: 150rpx;
  139. display: flex;
  140. flex-direction: column;
  141. justify-content: space-around;
  142. /* align-items: center; */
  143. background: #fff;
  144. font-size: 30rpx;
  145. }
  146. .price-style {
  147. /* margin-right: 75%; */
  148. margin-left: 4.5%;
  149. color: red;
  150. }
  151. .share-box {
  152. display: flex;
  153. flex-direction: column;
  154. justify-content: center;
  155. align-items: center;
  156. width: 80%;
  157. height: 300upx;
  158. border: 1px dashed red;
  159. background: #fff;
  160. font-size: 28rpx;
  161. padding: 5px;
  162. }
  163. .share-box button {
  164. width: 300rpx;
  165. height: 70rpx;
  166. line-height: 70rpx;
  167. margin-top: 2%;
  168. background-color: #27BCEF;
  169. color: #fff;
  170. }
  171. .title {
  172. font-size: 36upx;
  173. color: #8f8f94;
  174. }
  175. .product-title {
  176. margin-top: 2%;
  177. margin-bottom: 2%;
  178. font-size: 32rpx;
  179. }
  180. //分享模态框
  181. .uni-share-content {
  182. display: flex;
  183. flex-wrap: wrap;
  184. padding: 15px;
  185. /* justify-content: center */
  186. }
  187. .uni-share-content-box {
  188. display: flex;
  189. flex-direction: column;
  190. align-items: center;
  191. width: 25%;
  192. box-sizing: border-box;
  193. margin-left: 0;
  194. margin-right: 0;
  195. border: none;
  196. background: transparent;
  197. padding-left: 0;
  198. padding-right: 0;
  199. }
  200. .uni-share-content-box::after{
  201. border: none;
  202. }
  203. .uni-share-content-image {
  204. display: flex;
  205. justify-content: center;
  206. align-items: center;
  207. width: 60upx;
  208. height: 60upx;
  209. overflow: hidden;
  210. border-radius: 10upx;
  211. }
  212. .uni-share-content-image .image {
  213. width: 100%;
  214. height: 100%;
  215. }
  216. .uni-share-content-text {
  217. font-size: 26upx;
  218. color: #999;
  219. padding-top: 5px;
  220. // padding-bottom: 10px;
  221. }
  222. .uni-share-btn {
  223. height: 90upx;
  224. line-height: 90upx;
  225. border-top: 1px #f5f5f5 solid;
  226. text-align: center;
  227. color: #666;
  228. font-size: 30rpx;
  229. }
  230. </style>