index.vue 8.2 KB

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